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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 13:50, juan3937
The instruction ishl (shift left integer) exists in jvm but not in ijvm. it uses the top two values on the stack, replacing the two with a single value, the result. the sec- ond-from-top word of the stack is the operand to be shifted. its content is shifted left by a value between 0 and 31, inclusive, depending on the value of the 5 least signifi- cant bits of the top word on the stack (the other 27 bits of the top word are ignored). zeros are shifted in from the right for as many bits as the shift count. the opcode for ishl is 120 (0x78).a. what is the arithmetic operation equivalent to shifting left with a count of 2? b. extend the microcode to include this instruction as a part of ijv.
Answers: 1
image
Computers and Technology, 23.06.2019 17:00, Need1ng
The more powerful, 60 volt cables and the main power shut-off on an hev are both colored orange.
Answers: 1
image
Computers and Technology, 25.06.2019 03:00, brittanysanders
1. how do you view the edited document without the track changes markup? a. select accept all changes in document in the accept drop-down menu. b. click on restrict editing in the protect group. c. click on the reviewing pane drop-down menu in the tracking group. d. click on final in the display for review drop-down menu.
Answers: 3
image
Computers and Technology, 25.06.2019 09:00, pacetys
Which element of a presentation program’s interface displays the slide you are currently creating or editing? a. slide pane b. tool bar c. menu bar d. scroll bar
Answers: 1
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 in other subjects:

Konu
Mathematics, 27.01.2020 06:31
Konu
Biology, 27.01.2020 06:31