Write a C++ program that inputs two simplified poker hands (as
defined in homework #5) and
determines which (if either) of the hands is the winner,
according to the following rules:
• If the two hands have different types (3-of-kind, straight,
pair, high-card), the hand with
the better type (i.e., appears earlier in this list)
wins.
• If they have the same type, the higher significant card
wins.
• If the hands have the same type and significant card, there
is no winner (a tie).
• Note that the only significant factors are four types of
hand and what is the significant
card (high card or card in a pair/triple). In real poker, a
tie in the criteria above would be
resolved by comparing the non-pair or next-highest card. You
may do this if you wish,
but it is not required
Further Assignment Parameters:
Your program should be decomposed into functions and files.
You should not have more
than one function that does the same thing. For example, there
should be one function
(with three reference parameters) that inputs a hand. This
function can be used twice
(passing different cards as parameters) in order to input the
two hands.
• You may start with your solution to homework 5, or you may
start with my solution, or
you may start over. If you start with your solution, you
should deal with any concerns
that I wrote on it when I graded it. Note that much of this
homework involves
converting previous code into functions. There will be very
little new code, most of
which will be involved with comparing two hands in order to
select a winner.
• Use the existing tool functions from class lectures whenever
you can!
***Below is homework #5 (already done):
In the output, cards will be described as follows:
• 2-10 are described by the words for their numeric values:
two, three, etc.
• 1 is called an ace, 11 is called a jack, 12 is called a
queen, and 13 is called a king.
The evaluation of a hand is based on the first of the
following cases that matches the cards:
• All three cards are equal to each other.
Sample output for 4 4 4: You have three fours.
• The three cards form a straight (three successive
values).
Sample output for 68 7: You have an eight-high straight.
• Two cards (a pair) are equal.
Sample output for 6 3 6: You have a pair of sixes.
• Whatever is the highest card.
Sample output for 11 18: You have a jack.
I recommend sorting the card values before trying to evaluate
the hand - that makes it much
easier. Also, work on one thing at a time: first determine
what kind of hand (3 of kind, 2 of kind,
straight....) and then determine what is the "significant"
card for that hand (it becomes very
messy and exhausting if you try to do both at the same time!).
Check for card values being
equal to each other (card1 == card2), not specific values
(card1 == 1 && card2 == 1 || card1 ==
2 && card 2 == 2 || ...). If you check each value,
your program will be hundreds of lines long!