Question: Create an OO C++ text-based simulation that plays baccarat between two players. In baccarat, there is a banker and there is a player. Two cards
Create an OO C++ text-based simulation that plays baccarat between two players. In baccarat, there is a banker and there is a player. Two cards are dealt to the banker and two cards to the player. Both cards in each hand are added together, and the objective (player) is to draw a two or three-card hand that totals closer to 9 than the banker. In baccarat, the card values are as follows:
29 are worth face value
10, J, Q, K are worth 0
A is worth 1
The suits are the standard values. Players calculate their score by taking the sum of all cards modulo 10. In other words, after adding the value of the cards, the tens digit is ignored. So, for example, a hand consisting of 3 and 4 is worth 7. A hand consisting of 7 and 8 is worth 5 (15 % 10). A hand consisting of 5 and 5 is worth 0 (10 % 10). The highest point total that can be achieved is 9. After the player and the banker are dealt two cards each, an additional card is drawn depending on the following conditions:
If either the players hand or the bankers hand totals 8 or 9, both automatically stand, and a winner is determined.
If the players hand totals 6 or 7, the player stands.
If the player stands, the banker must draw a card if his/her hand totals 5 or less.
If the players hand is 5 or less, the player must draw another card.
If the player draws a third card, then the banker must draw a third card if: Bankers hand totals 0, 1, or 2.
Bankers hand totals 3 and the players total after drawing the third card is not 8.
Bankers hand totals 4 and the players total after drawing the third card is 2-7.
Bankers hand totals 5 and the players total after drawing the third card is 4-7.
Bankers hand totals 6 and the players total after drawing the third card is 6-7.
If the player draws a third card and the bankers hand totals 7, then the banker must stand with his two cards.
Once the final cards are dealt, the player with the total closest points to 9 wins. Betting:
If a third card needs to be dealt to the player, the banker or both, the player has an opportunity to make a bet greater than 0 and less than or equal to his/her current balance.
If the player loses the hand, the amount he/she bet gets deducted from the total. If the player wins the hand, he/she wins the bet amount. In the case of a tie, the amount of the bet is neither added nor deducted from the total. The player will begin with $500 and the default bet is $50. The only time the player can make a bet is if he/she and/or the banker must draw a card, at which point the player can bet any amount greater than 0 and less than or equal to the total. The game ends when the player loses all his/her money or decides to quit. Implementation:
The following class must be used:
Baccarat(object) - to represent the entire game. Creating a Baccarat object should start the game. Also, no object should directly examine or alter the variables of any other object; all access should be done by talking to (calling functions of) the other object. The student should figure out what the various classes and objects should be and what their instance variables and their functions should be. There is no single "correct" design; any reasonable design will do. The better the design, the easier the programming will be. Use the objects defined to play a game of Baccarat. Finally ask the user to play again. Place all classes into one file. Refer to the sample output below. Sample Run: The value of the player's hand is 7: 6C 9C 2S
The value of the banker's hand is 6: 8C 8D The player wins. Run again (Y/N)? y Player bets $: 400 The value of the player's hand is 0: QD 10C QS The value of the banker's hand is 7: 5S KS 2C The banker wins. Run again (Y/N)? n
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
