Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include #include #define SUITS 4 #define FACES 1 3 #define CARDS 5 2 #define HAND _ SIZE 5 #define HANDS _ IN _ DECK
#include
#include
#include
#define SUITS
#define FACES
#define CARDS
#define HANDSIZE
#define HANDSINDECK
#define NUMBEROFHANDSPLAYED Currently set to million
#define NUMBHANDSSTR million" Currently set to million
#define TRUE
#define FALSE
prototypes of functions supplied
void dealconst unsigned int wDeck const char wFacedisplay all cards in deck
const char wSuit;
void dealNextHandunsigned int wDeck unsigned int hand; deal out next hand from the deck
int isFourOfAKindconst unsigned int hand; return true if hand contains four of a kind and false otherwise
prototypes of functions you must implement
void swapunsigned int const, unsigned int const; swap the two cards pointed to by the pointers
void shuffleunsigned int wDeck; shuffle deck
int isPairconst unsigned int hand; return true if hand contains a pair and false otherwise
int isTwoPairconst unsigned int hand; return true if hand contains a two pair and false otherwise
int isThreeOfAKindconst unsigned int hand; return true if hand contains three of a kind and false otherwise
int isStraightconst unsigned int hand; return true if hand is a straight and false otherwise
int isFlushconst unsigned int hand; return true if hand is a flush and false otherwise
int isFullHouseconst unsigned int hand; return true if hand is a full house and false otherwise
int isRoyalFlushconst unsigned int hand; return true if hand is a royal flush and false otherwise
int mainvoid
define and initialize deck array
unsigned int deckCARDS;
initialize deck with values to CARDS
value caluclates suit # "Hearts", "Diamonds", "Clubs", "Spades" ;
value calculates face card Ace Jack, Queen, King
for sizet card ; card CARDS; card
deckcard card;
srandunsigned inttimeNULL; seed randomnumber generator
initialize suit array
const char suitSUITS
"Hearts", "Diamonds", "Clubs", "Spades" ;
initialize face array
const char faceFACES
"Ace", "Deuce", "Three", "Four",
"Five", "Six", "Seven", "Eight",
"Nine", "Ten", "Jack", "Queen", "King" ;
shuffledeck; uncomment after completing the implementation
of the swap and shuffle functions
dealdeck face, suit; display the deck unshuffled
unsigned int handHANDSIZE; will contain the cards in the hand.
Define and initialize variables used to count each type of hand
unsigned int pairCount ;
unsigned int twoPairCount ;
unsigned int threeOfAKindCount ;
unsigned int straightCount ;
unsigned int flushCount ;
unsigned int fullHouseCount ;
unsigned int fourOfAKindCount ;
unsigned int straightFlushCount ;
unsigned int royalFlushCount ;NOTE: This count includes both straight flushes and royal flushes.
Shuffle the deck for the first time
After this, we shuffle deck every time we do not have enough undealth cards
for a complete hand which will be every deals assuming five card hands
shuffledeck;
Deal out NUMBEROFHANDSPLAYED hands
for sizet hands ; hands NUMBEROFHANDSPLAYED; hands
dealNextHanddeck hand; Deal out next cards from the deck into the array hand
Does hand have a pair?
if isPairhand
pairCount; Yes, increment pair count
Does hand have two pair?
if isTwoPairhand
twoPairCount;
Does hand have three of a kind?
if isThreeOfAKindhand
threeOfAKindCount;
Does hand have a straight?
if isStraighthand
if isFlush
straightFlushCount; both straight and flush
else
straightCount; nope, just a straight
Does hand have a flush?
if isFlushhandnot a straight, how about a flush?
flushCount;
Does hand have a full house?
if isFullHousehand
fullHouseCount;
Does hand have four of a kind?
if isFourOfAKindhand
fourOfAKindCount;
int isFullHouseconst unsigned int hand
int isRoyalFlushconst unsigned int hand
int isStrightconst unsigned int hand
NOTE write code for just last functions also change if statement in main so straight do not count if a card is royal flush. royal flush in main's if statement.
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