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 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 ;
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
Check if also a flush
if isFlushhand
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;
Display all of the cards in the deck
void dealconst unsigned int wDeck const char wFace
const char wSuit
deal each of the cards
for sizet card ; card CARDS; card
sizet suit wDeckcard FACES;
sizet face wDeckcard FACES;
printfs of sc wFaceface wSuitsuit
card
: t; column format
void dealNextHandunsigned int wDeck unsigned int hand
static unsigned int currentCard ; remembers which is the next card to be dealt.
Shuffle deck and start from beginning of the deck if not enough cards left for a whole hand
if currentCard HANDSIZE CARDS
shufflewDeck;
currentCard ;
Deal out HANDSIZE cards from wDeck into the hand array
for sizet card ; card HANDSIZE; card
handcard wDeckcurrentCard;
void swapunsigned int const card unsigned int const card
Student implements this function
Shuffle cards in deck
Must invoke swap function above
void shuffleunsigned int wDeck
Student implements this function
Returns true if hand contains only a pair and false other wise.
Note: will return FALSE if the hand contains any of these hand types as well.
Hand has pairs.
hand has of kind
Hand is a full house
hand has of kind
int isPairconst unsigned int hand
NOTE ONLY C PROGRAMMING. ALL CODE IS PROVIDED JUST WRITE CODE FOR THE LAST FUNCTIONS.
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