Checkpoint 12.7.1.
A Euchre Deck contains 9’s, 10’s, Jacks, Queens, Kings, and Aces of all four suits. Modify the
buildDeck function below to create a Euchre deck. The printDeck function will allow you to verify that you have done this correctly.
Solution.
Hopefully you took some time to try and figure out the code yourself. The solution below is just one of several correct solutions for creating the Euchre deck:
vector<Card> buildEuchreDeck() {
vector<Card> deck(24);
int i = 0;
for (int suit = 0; suit <= 3; suit++) {
for (int rank = 1; rank <= 13; rank++) {
if (rank == 1 || rank >= 9) {
deck[i].suit = suit;
deck[i].rank = rank;
i++;
}
}
}
return deck;
}
