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 2210 <> 0000011010002 You have a PAIR! Use lots of small functions to help 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 faces InHand[14]. suits InHand 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 faces InHand 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 faces InHand. I will include some code below that will help 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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Coding in C!!! Fun assignment if you know what you're doing. The screenshot explains. Code is pasted below. 

/*
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 help 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");
 
 
 
 
 
 
 
3
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");

Include the output of running the program 10 times. Include several different cases, for example 2 pair,
High Card. 

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
2210
<<These are explained below>>
0000011010002
You have a PAIR!
Use lots of small functions to help 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].
suits InHand 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 help 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.
Transcribed Image Text: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 2210 <<These are explained below>> 0000011010002 You have a PAIR! Use lots of small functions to help 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]. suits InHand 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 help 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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education