Question: This program draws 5 random cards for the player. Please edit the following code to include another 5 cards drawn for the computer as the
This program draws 5 random cards for the "player". Please edit the following code to include another 5 cards drawn for the computer as the picture shows using the same struct.
#include
#include
#include
#include
#include
using namespace std;
struct card
{
string rank;
string suit;
int numeric;
bool drawn;
};
void printCard(card[]);
const int ranksize = 13;
const int suitsize = 4;
int main()
{
int counter =0;
srand(time(0));
bool drawn = false;
struct card deck[52];
string ranks[ranksize] = { "Ace", "2", "3", "4",
"5", "6", "7", "8",
"9", "10", "Jack", "Queen", "King" };
const string suits[suitsize] = { "Diamonds", "Hearts", "Spades", "Clubs" };
int k = 0;
for ( int i = 0; i
{
for ( int j = 0; j
{
deck[k].rank = ranks[i];
deck[k].suit = suits[j];
k++;
}
}
for (int counter=0; counter
int r = rand()%52;
struct card temp = deck[counter]; deck[counter] = deck[r]; deck[r] = temp;
}
printCard(deck);
return 0;
}
void printCard(card ca[])
{
int z=0;
cout
for (int z=0; z
cout
}
return;
}

Create a class named PlayingCard. The class contains four fields for a standard playing card a value in numeric (e.g. 12) a value in string format (e.g. "Queen") a suit in numeric (e.g. 1) a suit in string format (e.g. "spade") Each PlayingCard is assigned its values upon construction Write a main() function that plays a card game where the objective is to have the greatest number of pairs; a pair is composed of two cards of the same value in different suits. Randomly deal five cards each to a player and to a computer. Make sure there are no duplicate cards, as would be the case using a standard playing card deck. (For example, a deck can contain four fives and 13 spades, but only one five of spades.) Count the number of matching cards for the player and for the computer, and announce a winner or a tie For this game assume that a pair beats no matching cards, three of a kind beats a pair, four of a kind beats three of a kind, and five of a kind beats four of a kind. Card values do not affect the outcome-for example, two eights are no better than two sevens. Also assume two pairs are no better than a pair Sample run Player's cards Card is King of hearts Card is 7 of hearts Card is 9 of spades Card is 8 of clubs Card is Ace of spades Computer's cards Card IS 5 Of clubS Card is 8 of spades Card is 2 of diamonds Card is 9 of clubs Card is 6 of hearts Player has no p Computer has no pairs It's a tie airs
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
