I'm making a basic card game in c++ and I know my cards are getting created, I just don't know if they're even being put into the vector.
I've tried using functions to pass back the information, I've tested it out without shuffling to see if it at least detects the correct guesses.
struct card
{
string cardFace, cardSuit;
};
int main()
{
vector<card> deck;
card currentCard;
for (int i = 0; i < 4; i++)
{
string suits[4] = { "Hearts", "Diamonds", "Spades", "Clubs" };
for (int j = 1; j < 13; j++)//13 cards per suit
{
card a;
if (j == 1)
a.cardFace = "Ace";
if (j == 11)
a.cardFace = "Jack";
if (j == 12)
a.cardFace = "Queen";
if (j == 13)
a.cardFace = "King";
else
a.cardFace = to_string(j);
a.cardSuit = suits[i];
deck.push_back(a);
}
}
random_shuffle(deck.begin(), deck.end());
currentCard.cardFace = deck[0].cardFace;
currentCard.cardSuit = deck[0].cardSuit;
if(input == currentCard.cardFace)
cout << currentCard.cardFace << " is the right answer!" << endl;
return 0;
}
I expect the output to be: Jack is the right answer! but I got: is the right answer!
Aucun commentaire:
Enregistrer un commentaire