Finish this program that play cards that creates a deck of cards, shuffles them,
ID: 3653094 • Letter: F
Question
Finish this program that play cards that creates a deck of cards, shuffles them, and then lists them out. Modify the program to 'deal' two hands of cards (two players). Each player will be dealt 5 cards. Deal one to the first player, then one to second player. Repeat until both players have 5 cards in their hand. Then compute the total points in each player's hand and determine the winner with the most points. If a player has an ace, then count that as 11 points. . #include #include #include #define NCARDS 52 #define NPROPS 2 #define NSUITS 4 #define NFACES 13 char* suit[NSUITS]={"hearts","spades","clubs","diamonds"}; char* face[NFACES]={"ace","two","three","four","five","six","seven","eight","nine", "ten","jack","queen","king"}; void PrintCard(int deck[NCARDS][NPROPS], int i); void InitDeck(int deck[NCARDS][NPROPS]); void SwapCards(int deck[NCARDS][NPROPS], int src, int dest); void ShuffleDeck(int deck[NCARDS][NPROPS]); int GetPlayValue(int deck[NCARDS][NPROPS], int i); int main() { int deck[NCARDS][NPROPS]; int src; int dest; int i; srand(time(NULL)); printf(" Initializing the deck... "); InitDeck(deck); printf(" Shuffling the deck... "); ShuffleDeck(deck); for (i=0; i<4; suit++) for (face=0; face<13; face++) { deck[row][0]= suit; deck[row][1]= face; row++; } } void ShuffleDeck(int deck[NCARDS][NPROPS]) { int src, dest, i; for (i=0; i 0) && (face < 10)) return face+1; else return 10; }Explanation / Answer
// 02 // Lab 4 03 // Card Shuffling and Dealing 04 05 06 #include 07 #include 08 #include 09 #include 10 using namespace std; 11 12 string suits[4]={"Hearts", "Diamonds", "Spades", "Clubs"}; 13 string faces[12]={"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "Jack", "Queen", "King"}; 14 15 16 class Card 17 { 18 public: 19 int face,suit; 20 Card(int face,int suit) 21 { 22 this->face=face; 23 this->suit=suit; 24 } 25 string toString() 26 { 27 string nameSuit = suits[suit]; 28 string nameFace = faces[face]; 29 30 return nameFace+" of "+nameSuit; 31 } 32 33 }; 34 35 class DeckOfCards 36 { 37 private: 38 vector deck; 39 int currentLocation, location; 40 41 public: 42 DeckOfCards() 43 /*create deck*/ 44 { 45 for(int i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.