Question: C++ Programming I need some help modifying my program Here is what I need to change. Use the Poker classes to write a program that

C++ Programming

I need some help modifying my program Here is what I need to change.

Use the Poker classes to write a program that deals two five-card poker hands, evaluates each hand and determines which is the better hand.

Modify this program so that it can simulate the dealer. The dealers five-card hand is dealt face down so the player can not see it. The program should then evaluate the dealers hand, and, based on the quality of the hand, the dealer should draw one, two or three more cards to replace the corresponding number of unneeded cards in the original hand. The program should then reevaluate the dealers hand.

Modify this program you so that it handles the dealers hand, but the player is allowed to decide which cards of the players hand to replace. The program should then evaluate both hands and determine who wins. Now use this new program to play 5 games against the computer. Keep track of who wins more games, you or the computer.

Provide a somewhat attractive (you don't have to go overboard) text based user interface to allow the user to play poker against the dealer and reports what the final results were of the 5 poker games.

This is my program

#include #include #include "CardH.h" #include

using namespace std;

string Card::suits[4] = {"Diamonds","Clubs","Hearts","Spades"}; string Card::faces[13] = {"Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine", "Ten","Jack","Queen","King"};

Card::Card(int type,int num) { suit = suits[type]; face = faces[num]; }

void Card::toString() { string printout = " A " + face + " of " + suit; cout << printout << endl << endl; }

string Card::getFace() { return face; }

string Card::getSuit() { return suit; }

__________________________________________________________

#ifndef CARD_H #define CARD_H

#include #include using namespace std;

class Card { private: string face; string suit; public: static string faces[13]; static string suits[4]; string getFace(); string getSuit(); Card(int, int); void toString(); };

#endif

_____________________________________________

#include #include #include #include "DeckOfCardsH.h"

DeckOfCards::DeckOfCards() { currentCard = 0; for( int i=0; i<4; i++){ for(int j=0; j<13; j++){ Card c = Card(i,j); deck.push_back(c); } }

} void DeckOfCards::swap(Card &first, Card &second) { Card temp = first ; first = second; second = temp; } void DeckOfCards::shuffle(){ time_t t; srand(time(&t)); for(int i=0; i<52; i++) { int s = rand()%52; swap (deck.at(i),deck.at(s)); } }

Card DeckOfCards::dealCard() { currentCard++; shuffle(); if (moreCards()) { return deck[currentCard - 1]; } else { cout << "The deck is empty " << endl; } }

bool DeckOfCards::moreCards() {

if (currentCard < 52) { return true; } else { return false; }

}

____________________________________________________________________________

#ifndef DECKOFCARD_H #define DECKOFCARD_H #include #include "CardH.h"

class DeckOfCards { private: vectordeck; int currentCard; void swap(Card &first, Card &second); public: DeckOfCards(); void shuffle(); Card dealCard(); bool moreCards(); };

#endif

_______________________________________________________

#include #include #include #include "CardH.h" #include "DeckOfCardsH.h"

using namespace std;

int main(int argc, char *argv[]) { DeckOfCards d = DeckOfCards(); vectorhand; cout << " You have been delt: " << endl; for (int i=0;i<5;i++) { hand.push_back(d.dealCard()); hand[i].toString(); } int flag = 0; for (int i=0;i<5;i++) { for (int j= i+1;j<5;j++) { if ((hand[i].getFace()).compare(hand[j].getFace()) == 0 && i !=j) { flag++; } } } if(flag == 1) { cout << "You have been delt a pair! " << endl; } if (flag > 1) { cout << "You have been delt two pair! " << endl; } flag = 0; for (int i=0;i<5;i++) { for (int j= i+1;j<5;j++) { for (int k= j+1; k<5;k++) { if ((hand[i].getFace()).compare(hand[j].getFace()) == 0 && (hand[i].getFace()).compare(hand[k].getFace()) == 0 && i !=j != k) { flag++; } } } } if (flag) { cout << "You have been delt Three of a kind! " << endl; flag = 0; } if ((hand[0].getSuit()).compare(hand[1].getSuit()) == 0 && (hand[0].getSuit()).compare(hand[2].getSuit()) == 0 && (hand[0].getSuit()).compare(hand[3].getSuit()) == 0 && (hand[0].getSuit()).compare(hand[4].getSuit()) == 0) { cout << "You have been delt a flush! " << endl; vectorv; for (int i=0;i<5;i++) { for (int j=0;j<13;j++) { if ((hand[i].getFace()).compare(hand[i].faces[j]) == 0) { v.push_back(j+1); } } } sort(v.begin(),v.end()); if (v[0] == v[1]-1 && v[0] == v[2]-2 && v[0] == v[3]-3 && v[0] == v[4]-4) { cout << "You have been delt a straight! " << endl; } } system ("pause"); return 0;

}

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!