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 }
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; i4;> for(int j=0; j13;> 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; i52;> { int s = rand()%52; swap (deck.at(i),deck.at(s)); } }
Card DeckOfCards::dealCard() { currentCard++; shuffle(); if (moreCards()) { return deck[currentCard - 1]; } else { cout } }
bool DeckOfCards::moreCards() {
if (currentCard { 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 for (int i=0;i { hand.push_back(d.dealCard()); hand[i].toString(); } int flag = 0; for (int i=0;i { for (int j= i+1;j { if ((hand[i].getFace()).compare(hand[j].getFace()) == 0 && i !=j) { flag++; } } } if(flag == 1) { cout } if (flag > 1) { cout } flag = 0; for (int i=0;i { for (int j= i+1;j { for (int k= j+1; 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 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 vectorv; for (int i=0;i { for (int j=0;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 } } system ("pause"); return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started