Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ CODE! Hello Experts, Question below is continually adding stuff to previous code, I have attached the code below. The question is the screenshot. You

C++ CODE! Hello Experts, Question below is continually adding stuff to previous code, I have attached the code below. The question is the screenshot.

You can make your own code but please add separate header files and cpp as per the requirements and previous code

image text in transcribed

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

// main.cpp

#include "card.h"

#include

#include

#include

#include

using namespace std;

void shuffleDeck(vector *carddeck) {

mt19937 range;

range.seed(random_device()());

uniform_int_distribution<:mt19937::result_type> d(0, 115);

for (int i = 0; i size(); i++) {

int rndIndex = d(range);

Card rndCard = carddeck->at(rndIndex);

(*carddeck)[rndIndex] = (*carddeck)[i];

(*carddeck)[i] = rndCard;

}

}

int main() {

vector carddeck;

for (int s = Clubs; s

for (int f = Three; f

Card card = Card(static_cast(f), static_cast(s));

carddeck.push_back(card);

carddeck.push_back(card);

}

}

for (int i = 0; i

Card card = Card(Joker, NotAvailable);

carddeck.push_back(card);

}

for (int i = 0; i

cout

}

shuffleDeck(&carddeck);

cout

for (int i = 0; i

cout

}

system("pause");

}

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

// card.h

#pragma once

#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();

};

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

// card.cpp

#include "card.h"

#include

#include

using namespace std;

string getSuit(Suits s)

{

switch (s)

{

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 getFace(Faces f) {

switch (f) {

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 f, Suits s) {

this->face = f;

this->suit = s;

}

string Card::toString() {

if (this->face == Joker)

return "Joker";

return getFace(face) + " of " + getSuit(suit);

}

1. You will create a class Deck that consists of the following The vector of 116 cards from last week's program. a method to deal a card from the deck a. b. 2. You will create a class Hand that consists of the following a. a method to add a card (taken from the deck) to the hand. b. a method to determine the value of a hand. c. a method to determine the number of cards in the hand d. a method that displays the contents of the hand and its value (i.e. toString Create a Hand for each player that consists of nine cards from the Five Crowns part 1 program. operator to check if two cards are equal (same that overloads the-: operator to check if two hands are equal (equal 3. 4. Create overloaded operators: a. bool operatorthat overloads the face) bool operator value). bool operator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions