Question
Code should be in C++. Please Help. Thank you!! Consider a very simple card game we will call Three-Card High-Card . In this game, each
Code should be in C++. Please Help. Thank you!!
Consider a very simple card game we will call Three-Card High-Card. In this game, each player is dealt three cards. The player with the highest card wins. If there is a tie for the highest card, the player with the second highest card wins. If a tie for the two highest cards, the tie is broken by the third, lowest card. Cards are ranked according to common Ace-high ordering and suits are not considered in ranking.
Using the inheritance mechanism in C++, create a class called ThreeCardHand that used Hand as its base class (use the cards library that was developed in class, which is included in the starter code for this project). Your inherited class will need some way of ranking the objects so that they can be compared to determine which is the winner (similar to the rank method we included for the Card class).
Once you have build your ThreeCardHand class, write a main function that simulates 5 rounds of this game between two players from the same deck without shuffling, then shuffles the deck bring it back to 52 cards, then simulates 5 rounds of the game again. Each game simulation should show both hands, then show the hand of the winner. Format your output like the sample output shown below.
Sumulating 10 games of Three-Card High-Card. Game 1 4S-7C-7H vs TS-8S-2C - Winner is TS-8S-2C Game 2 2H-QS-3S vs 9D-5D-5C - Winner is 2H-QS-3S Game 3 QC-KD-9H vs 6C-4H-6H - Winner is QC-KD-9H Game 4 JH-3D-8D vs AD-2D-4D - Winner is AD-2D-4D Game 5 QD-KS-4C vs TC-6D-TH - Winner is QD-KS-4C Shuffling... Game 6 TH-2C-JH vs 3S-TD-TC - Winner is TH-2C-JH Game 7 6C-7H-TS vs JC-9C-AC - Winner is JC-9C-AC Game 8 4D-5H-9D vs 6S-2D-5C - Winner is 4D-5H-9D Game 9 4H-JD-4C vs JS-QD-8S - Winner is JS-QD-8S Game 10 QH-9H-3C vs AS-AH-KH - Winner is AS-AH-KH
There should be no need to modify cards.h or cards.cpp for this project. You may, at your option, implement this new class in its own header and implementation file, or in main.cpp.
Ranking Hint
In order to compare hands you will need some basis of comparison, similar to the rank method implemented for the Card class. You might calculate a rank by taking the rank of the highest card times 10000, the rank of the middle card times 100, and the rank of the lowest card, and adding those three values together.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started