subject

In this assignment we will work on the creation of a poker game. at a minimum your game must deal 2 hands of cards, and print out what poker hand each has. it must also determine which hand has won the game – but breaking a tie will be for bonus points. for example, if both hands have 3 of a kind, that can be considered a tie. if you want the bonus points write some code that determines which 3 of a kind is higher.

here is the output from dealing a hand of cards:

ace of hearts
ten of clubs
ace of clubs
eight of hearts
seven of diamonds

2 2 1 0 < > 0 0 0 0 0 1 1 0 1 0 0 0 2

you have a pair!

use lots of small functions to reduce the complexity of the code.
you must use the code from the video to get started, and you must use the following representation for a poker hand:
make 2 arrays: suitsinhand[4], and facesinhand[14].
suitsinhand is 4 counters that represents how many hearts, clubs, diamonds, spades are in the hand. these 4 counters must add up to 5 for a hand of 5 cards. for example if you have 5 hearts in the hand of cards, the array would have the values 5,0,0,0
facesinhand is 13 counters, that represent how many two’s, three’s, etc. you have in the hand. this must also total 5. for example, if you have a pair of 3’s, and three kings’s, this array would have the values 0,2,0,0,0,0,0,0,0,0,3,0

while dealing a hand of cards, keep a count of the suitsinhand, and facesinhand.

i will include some code below that will you to figure out what poker hand you have dealt.
this function will use the 2 arrays described above to determine if the hand has a flush, straight, etc. i have not included the parameters. you will need to pass in the hand of cards, and have the function pass back if there is a flush, straight, three of a kind, etc.

/* analyzehand: determines whether the hand contains a straight, a flush, four-of-a-kind, and/or a three-of-a-kind; determines the number of pairs; stores the results into the external variables straight, flush, four, three, and pairs. */

void analyzehand( …
{ int num_consec = 0;
int rank, suit;
straight = false;
flush = false;
four = false;
three = false;
pairs = 0;

// check for flush – 5 cards of the same suit

for (suit = 0; suit < suits; suit++)

if (suitsinhand[suit] == 5)

flush = true;

// check for straight – eg. one each of 5,6,7,8,9

// locate the first card rank = 0;

while (facesinhand[rank] == 0)

rank++;

// count the consecutive non-zero faces

for (; rank < faces & & facesinhand[rank]; rank++)

num_consec++;

if (num_consec == 5) {

straight = true;

return;

}

/* check for 4-of-a-kind, 3-of-a-kind, and pairs */

for (rank = 0; rank < num_ranks; rank++) {

if (facesinhand[rank] == 4)

four = true;

if (facesinhand[rank] == 3)

three = true;

if (facesinhand[rank] == 2)

pairs++;

}

}

here is a block of code that might you determine what hand is better than another. these are in order. a straight-flush is the best hand, and a high-card is the worst hand.

if (straight & & flush)
printf("straight flush\n\n");
else if (four)
printf("four of a kind\n\n");
else if (three & & pairs == 1)
printf("full house\n\n");
else if (flush)
printf("flush\n\n");
else if (straight)
printf("straight\n\n");
else if (three)
printf("three of a kind\n\n");
else if (pairs == 2)
printf("two pairs\n\n");
else if (pairs == 1)
printf("pair\n\n");
else printf("high card\n\n");
deliverables: 1. paste your code below, in this document.

2. include the output of running the program 10 times. include several different cases, for example 2 pair, high card. each case that you expect points for will be demonstrated in the output.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 23:00
Which type of tab stop is most for weights and measurements?
Answers: 1
question
Computers and Technology, 24.06.2019 17:30
What is the main difference between cloud computing and saas? cloud computing is a platform, and saas is software. cloud computing is software, and saas is a platform. cloud computing is a service, and saas is software. cloud computing is a service, and saas is a platform.
Answers: 1
question
Computers and Technology, 25.06.2019 02:30
How to delete a question in
Answers: 2
question
Computers and Technology, 25.06.2019 02:30
On the pie chart below, which “slice” represents 30% of the budget?
Answers: 2
You know the right answer?
In this assignment we will work on the creation of a poker game. at a minimum your game must deal 2...
Questions
question
Mathematics, 10.10.2021 14:00
question
Mathematics, 10.10.2021 14:00
question
Physics, 10.10.2021 14:00
question
Mathematics, 10.10.2021 14:00