Question: ADJUST previous program1. You will create a class Deck that consists of the following: a. The vector of 116 cards from last weeks program. b.

ADJUST previous program1. You will create a class Deck that consists of the following:

a. The vector of 116 cards from last weeks program.

b. a method to deal a card from the deck

2. Create overloaded operators:

a. bool operator == that overloads the == operator to check if two cards are equal.

b. bool operator

3. Create a Hand for each player that consists of nine cards from last weeks program.

Program main that will do the following:

Create the deck.

Shuffle the deck.

Print the deck.

Prompt the user for the number of players, and accept a value from 2 to 7 (reject any other values).

Deal hands of nine cards to each player.

Print the hands.

Evaluate each hand. Determine if any cards are equal to each other (i.e. pairs) and print the result.

Adjust program below with above instructions

cards.h

#include #include using namespace std; enum faces { Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Joker }; enum suits { Clubs, Diamonds, Hearts, Spades, Stars, NotAvailable }; class Card { public: faces face; suits suit; Card(faces face, suits suit); string toString(); };

cards.cpp

#include #include #include "cards.h" using namespace std;

string getTextForSuit(suits suit) { switch (suit) { case Clubs: return "Clubs";

case Diamonds: return "Diamonds";

case Hearts: return "Hearts";

case Spades: return "Spades";

case Stars: return "Stars";

default: return "Not recognized.."; } }

string getTextForFace(faces face) { switch (face) { case Three: return "Three"; case Four: return "Four"; case Five: return "Five"; case Six: return "Six"; case Seven: return "Seven"; case Eight: return "Eight"; case Nine: return "Nine"; case Ten: return "Ten"; case Jack: return "Jack"; case Queen: return "Queen"; case King: return "King"; default: return "Not recognized.."; } }

Card::Card(faces face, suits suit) { this->face = face; this->suit = suit; }

string Card::toString() { if (this->face == Joker) return "Joker"; return getTextForFace(face) + " of " + getTextForSuit(suit); }

cardsimplementation.cpp

#include #include #include #include #include "cards.cpp" using namespace std;

void shuffleDeck(vector *deck) { mt19937 rng; rng.seed(random_device()()); uniform_int_distribution<:mt19937::result_type> dist(0, 115); for (int i = 0; i size(); i++) { int randomIndex = dist(rng); Card randomCard = deck->at(randomIndex); (*deck)[randomIndex] = (*deck)[i]; (*deck)[i] = randomCard;

}

}

int main() { vector deck; for (int suit = Clubs; suit (face), static_cast(suit)); deck.push_back(newCard); deck.push_back(newCard); } }

for (int i = 0; i

for (int i = 0; i

shuffleDeck(&deck); cout

for (int i = 0; i

ADJUST previous program1. You will create a class Deck that consists ofthe following: a. The vector of 116 cards from last weeks program.

CAUsers charlie all stud 2015ProjectsAcardsimplementationVDebuglcardsimplementation.exe Nincspade KingDiamond ghtst Queenspad Eight Diamonds Queenspad espada ghtst Kingspade Four Spada rspada ghtspad kspada 2-13 PM 2/2s 2017 R190

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!