C++ Blackjack (21) Game Development Program - Assignment Solution

Verified

Added on  2019/09/25

|2
|783
|279
Homework Assignment
AI Summary
This assignment solution presents a C++ program designed to simulate the game of Blackjack (21). The program adheres to the standard rules of Blackjack, where the player competes against the computer. It involves dealing cards randomly from a single deck, managing card values, and determining the winner based on the closest score to 21 without exceeding it. The program includes features like displaying game rules, tracking dealt cards to prevent duplicates, shuffling the deck when necessary, displaying player and computer hands, and calculating win percentages. The solution includes the source code, screenshots of the program's functionality, and a detailed explanation of the game logic, variables used, and major program components. The program allows the user to play multiple rounds and provides a summary of the game results at the end, including the number of games played and the player's win percentage.
Document Page
Advanced c++ – Playing Blackjack (21)
400 points – Due Date – Dec 9 - NO late assignments will be accepted.
You are to create a program to play 21(blackjack) against the computer.
The rules of blackjack can be found on many internet sites. You will use the basic rules, no
splitting etc... Example of the rules are as follows:
The dealer gives one card face up to each player, and then one card face up to himself. Another round
of cards is then dealt face up to each player, but the dealer takes his second card face down. Thus, each
player except the dealer receives two cards face up, and the dealer receives one card face up and one
card face down.
Each player must decide whether to "stand" (not ask for another card) or "hit" (ask for another card in an
attempt to get closer to a count of 21, or even hit 21 exactly). Thus, a player may stand on the two cards
originally dealt him, or he may ask the dealer for additional cards, one at a time, until he either decides
to stand on the total (if it is 21 or under), or goes "bust" (if it is over 21). –Each player attempts to beat
the dealer by getting a count as close to 21 as possible, without going over 21.
When the dealer has served the player, his face-down card is turned up. If the total is 17 or more, he
must stand. If the total is 16 or under, he must take a card. He must continue to take cards until the total
is 17 or more, at which point the dealer must stand. If the dealer has an ace, and counting it as 11 would
bring his total to 17 or more (but not over 21), he must count the ace as 11 and stand. The dealer's
decisions, then, are automatic on all plays, whereas the player always has the option of taking one or
more cards.
You may choose any logic/data structure you like for this program, but you must at least
do the following:
You will display the 21 rules you are using for your program
You will use only one deck of cards, see below:
Example set of 52 playing cards; 13 of each suit clubs, diamonds, hearts, and spades (you will NOT be using
graphics in this program… only the name and type of the card will be displayed)
Ace 2 3 4 5 6 7 8 9 10 Jack Queen King
Clubs
Diamonds
Hearts
Spades
You must load all cards into memory when your game begins. (this has been done for
you in the play21.cpp file and you must use this data structure). You will deal cards
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
(randomly) until there are only15 cards left undealt. Then you will reshuffle (reload all
52 cards again). You are NOT allowed to deal the same card more than once. Therefore,
you will have to keep track if the card has been dealt. Remember that you will be using a
random number generator to deal the cards. If the card has been dealt already, you will
have to generate another card.
You are to display all of the player cards and the computer hand as well
After a hand has been won, (either by the computer or the player) you are to ask the user
if he wants to play again. Your program will run until the player wants to stop.
You are to print a final summary of how many games were played, how many times the
player won and how many times the computer won along with the percentages of wins
for the player
You are to create a word document having the following:
1. Your name and date
2. A short explanation of the game and how it works
3. List of all major variables used in your program and what they are used for
4. Source Code
5. Screen shots displaying all major functionality and the final output
Upload the document to the blackboard
***Please note that this program must use the set of cards that are
defined in the program play21.cpp***
chevron_up_icon
1 out of 2
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]