Я использовал Microsoft Visual Studio для запуска этой программы. Пожалуйста, помогите внести изменения в файл card.cpp и deck.cpp . Мне нужно для вывода: < /p>
The cards in your hand are:
♥ A♥ ♠ A♠ ♥ K♥ ♠ K♠ ♥ Q♥ ♠ Q♠ ♥ J♥ ♠ J♠
♥10♥ ♠10♠ ♥ 9♥ ♠ 9♠ ♥ 8♥ ♠ 8♠ ♥ 7♥ ♠ 7♠
♥ 6♥ ♠ 6♠ ♥ 5♥ ♠ 5♠ ♥ 4♥ ♠ 4♠ ♥ 3♥ ♠ 3♠
♥ 2♥ ♠ 2♠
The cards in my hand are:
♣ A♣ ♦ A♦ ♣ K♣ ♦ K♦ ♣ Q♣ ♦ Q♦ ♣ J♣ ♦ J♦
♣10♣ ♦10♦ ♣ 9♣ ♦ 9♦ ♣ 8♣ ♦ 8♦ ♣ 7♣ ♦ 7♦
♣ 6♣ ♦ 6♦ ♣ 5♣ ♦ 5♦ ♣ 4♣ ♦ 4♦ ♣ 3♣ ♦ 3♦
♣ 2♣ ♦ 2♦
< /code>
Тем не менее, он не распознает символы или правильное расстояние < /p>
Это основная функция .cpp Не редактировать: < /p>
#include
#include "card.h"
#include "deck.h"
using namespace std;
int main()
{
// Avoid magic numbers
const int HANDS = 26; // each player holds half cards (52 cards / 2 = 26 cards) to begin the game
// create an object of Deck class to represent standard 52-card deck
// create a 52-card deck first
// then shuffle the cards
Deck playDeck;
playDeck.createDeck();
//playDeck.shuffleDeck();
Card yourCards[HANDS];
Card myCards[HANDS];
for (int i = 0; i < HANDS; i++)
{
yourCards = playDeck.deal_a_card();
myCards = playDeck.deal_a_card();
}
cout 3->…->14
void createDeck();
// shuffle the cards in 52-card deck
void shuffleDeck();
// return a card from the tail of the deck
Card deal_a_card();
private:
vector deck; // store the Card objects in the vector to present current cards on the deck
// each Card object represents a valid card from standard 52-card game, no duplicate cards
};
#endif /* DECK_H */
< /code>
Это должно быть исправлено, card.cpp: < /p>
#include "card.h"
#include
// Default constructor: uninitialized Card object
Card::Card() : suit('I'), point(0) {}
// Alternate constructor: creates a Card object with specified suit and points
Card::Card(char s, int p) : suit(s), point(p) {}
// Accessor for the card's point value
int Card::getPoint() const {
return point;
}
// Accessor for the card's suit value
char Card::getSuit() const {
return suit;
}
// Comparison method for card objects
int Card::compareTo(Card other) const {
if (point > other.point) {
return 1;
}
else if (point < other.point) {
return -1;
}
else {
return 0;
}
}
void Card::print() const {
if (point < 11) {
switch (suit) {
case 'S': cout
Подробнее здесь: https://stackoverflow.com/questions/795 ... ncorrectly
Неверно вывод костюмов и расстояния ⇐ C++
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Заполнить 52-канальный массив имен карт из множества костюмов и множества рядов
Anonymous » » в форуме Php - 0 Ответы
- 31 Просмотры
-
Последнее сообщение Anonymous
-