Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this project you will need to design 2 classes: PlayingCard and Deck. You can read more details about each of them below. This means

For this project you will need to design 2 classes: PlayingCard and Deck. You can read more details about each of them below. This means your complete program will contain a minimum of 5 files:
The PlayingCard class's header file
The PlayingCard class's function definitions file
The Deck class's header file
The Deck class's function definitions file
The main program file
Since certain parts of the program depend on other parts, I recommend completing the program files in the order above. Since you are primarily writing classes for this project, you will probably not write your main function until the end. For this reason, you may want to temporarily include main function drivers in your class files for the purposes of testing them.
The PlayingCard Class
The PlayingCard class needs to be able to perform the following tasks:
Store the card's value
Store the card's suit
Obtain the card's value
Obtain the card's suit
Print the card's information
Playing cards come in 4 suits: spades, diamonds, clubs, and hearts. For each suit, there are 13 values: ace, 2,3,4,5,6,7,8,9,10, jack, queen, and king. A single card is made up of a suit and a value, such as "7 of spades" or "Ace of hearts".
The values of the cards are given an order where higher cards are more preferable. So a 9 is higher than a 7. Jack is higher than 10, queen is higher than jack, and king is higher than queen. Aces are considered the highest card (above a king), but in some cases can also count as a 1, which places them before the 2 card.
It is up to you to decide how best to store the information about the value and suit of each card. Bear in mind that you will need to use that information to compare different cards later. You will also need to be able to print the name of each card.
The Deck Class
The Deck class will utilize the PlayingCard class and needs to be able to perform the following tasks:
Start with a standard playing card deck, shuffled
Deal cards from the deck
Refill and reshuffle the deck
A deck consists of exactly 52 cards, one of each unique combination of suit and value of playing cards. There are no duplicate cards in the deck.
Shuffling the deck means randomizing the order of the cards. You can accomplish this by doing the following:
Fill the deck with the cards in any order
Starting with the first card, pick a random index of the array (for an array of 52 cards, that would be a random number between 0-51)
Swap the first card with the card located at that random index
Go to the second card in the deck and pick another random index, and swap it with the card at that index
Repeat this process for all cards in the array
"Dealing a card" simply means taking one card from the deck, usually from the top. If a card is dealt from the deck, then it is removed and cannot be dealt again until the deck has been reshuffled. If all 52 cards are drawn, then the deck will be empty and no more cards can be drawn until it is reshuffled.
Refilling and reshuffling the deck means starting the deck over from a full, shuffled state. After reshuffling, all 52 cards can be drawn again and appear in a new random order. Note that your deck class is required to be able to do this even though you may not use it in the main program.
The Main Program
The main program will utilize the Deck class and will perform the following steps in order:
Create a Deck object
Make sure the deck is shuffled
Deal 5 cards from the deck
Show what those 5 cards are
Determine if those 5 cards match any type of hand in Poker
Display the name of the best applicable Poker hand
The hands in Poker are as follows, in order from best to worst:
Royal Flush - an Ace, King, Queen, Jack, and 10, all of the same suit
Straight Flush -5 cards in sequential order of values, all of the same suit
Four of a Kind - any 4 cards with the same value (not suit)
Full House - a combination of a 3 of a kind and a pair in the same hand
Flush -5 cards with the same suit (any values)
Straight -5 cards in sequential order of values
Three of a Kind - any 3 cards with the same value
Two Pair - two different pairs of cards in the same hand
One Pair - any two numerically matching cards
If none of the above apply, we simply look at the highest value card in the hand
You only need to display the name of the best hand, even if multiple hands apply (for instance, every Full House also matches a Three of a Kind, so in that case you only display the higher ranking hand: the Full House).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started