Starting from:

$29.99

Lab 5: Vegas Blackjack

Lab 5: Vegas Blackjack
In this lab we will be writing a text-based computer game based upon a card game, casino blackjack.
Description and Rules of Blackjack You can find many descriptions of blackjack online. There are several variants of the game. The rules we will use are similar to those used in most American casinos. Your program must adhere to the rules as described below. Your program will have only a single player (the person running the program) and the dealer, whose actions will be determined by the program. The player is playing against the dealer. Blackjack is played in rounds. The cards held by the player during a round are called the player’s hand. The player’s objective in each round is to obtain a hand value higher than the dealer’s hand value, without exceeding 21. The value of each card is as follows: Card 2 3 4 5 6 7 8 9 10 Jack Queen King Ace Value 2 3 4 5 6 7 8 9 10 10 10 10 11 or 1 (Cards also have ‘suits’: Spades, Clubs, Hearts, or Diamonds, but this is irrelevant to this game.) The hand value is the sum of the card values in the hand. For example, if the player has a hand consisting of a 6 and a Queen, the player’s hand value is 16. An Ace can have a value of 11 or 1, depending on which value is better for the person holding the hand. For example, if the player or dealer has a hand consisting of a 7 and an Ace, the hand value is 18. However, if the player or dealer has a hand consisting of a 7, an Ace, and a 6, the hand value is 14, because if the Ace’s value were 11 the hand value would exceed 21, which is undesirable.
A round of blackjack is played as follows. Two cards are given (dealt) to the player and two cards to the dealer. The player is shown all of the cards in their hand, but only shown one of the dealer’s cards. If the player’s hand value at this point equals 21, the player has blackjack, and the player automatically wins the round unless the dealer also has blackjack, which results in a tie (known as a push). If the player does not have blackjack, the player may choose to ‘hit’ or ‘stand’. Choosing to hit means one card is added to the player’s hand. The player may continue to hit as many times as they wish, as long as their hand value does not equal or exceed 21. If the player’s hand value exceeds 21, the player has busted, and automatically loses the round regardless of the dealer’s hand. When the player no longer wishes to hit, or has a hand value equal to 21, the player stands, which transfers play to the dealer. From this point forward, the player is shown all of the dealer’s cards. The dealer’s hand is similar to the player’s, but the dealer has no choices to make. If the dealer’s hand value is 21 with only two cards, the dealer has blackjack, and the player loses (unless the player also has blackjack, as described above). If the dealer does not have blackjack, the dealer must continue to hit as long as the dealer’s hand value is less than 17, and must stand if the dealer’s hand value is equal to or greater than 17. The dealer’s Aces are always taken to have a value of 11 unless doing so would cause the dealer’s hand value to exceed 21 (in casino lingo, we require the dealer to stand on a soft 17). If the dealer’s hand value exceeds 21, the dealer has busted, and the player wins unless the player has also busted (in which case the player loses). After both player and dealer are done, the hand values are compared. The winning hand has the highest value without exceeding 21. If the hand values are equal, the player and dealer push (tie). As described above, a blackjack (a hand value of 21 with only two cards in the hand) beats any other hand, including a hand with more than two cards whose value is 21. The player places a monetary bet before each round of blackjack. If the player wins the round with a blackjack, they receive money equal to 1.5 times their bet. If the player wins the round with any hand other than a blackjack, they receive money equal to their bet. If the player pushes with the dealer, no money is received or lost. If the player loses the round, they lose money equal to their bet. For this program, the player will start with 300 dollars, and will be allowed to bet and play rounds until they run out of money or quit the game. Quitting the game will be indicated by the player placing a bet of 0 dollars. Players should not be allowed to place a bet larger than the amount of money they have! We will assume that the hands are dealt from an infinite deck of cards, so that any card is equally likely to be dealt at any time. (In the real world, some players use ‘card counting’ and exploit the finite size of the deck to determine the relative probability of certain cards being dealt. Casinos often ban players suspected of doing this.) When adding a card to a hand, your program should randomly select a number from 1 to 13, and add the card corresponding to the number selected.
Extra credit 5 points of extra credit will be awarded for correctly implementing ‘double down’. Doubling down is a choice a player may make which is similar to asking for a hit, but with the following conditions: • doubling down can only be done when the player’s hand has only two cards (right after dealing and checking for blackjacks) • the player’s bet on the round is doubled • a single card is added to the player’s hand and then the player is required to stand (the player is not allowed to hit more than once after doubling down). • http://www.youtube.com/watch?v=dxlbeqeGkQ8
You may choose to implement a more realistic finite-sized card deck from which the hands are dealt. However, you will not receive extra credit for doing so.
Detailed Lab Programming Requirements Your code must use the classes ‘Card’, ‘Hand’, and ‘Blackjack’ described in Card.h, Hand.h and Blackjack.h files provided by the instructor. The instructor will also provide the main.cpp file. Download these files from t-square. There are additional requirements described in the comments of these files. Your final code must use all of the above files with no modifications whatsoever, with one exception: you may make additions to Blackjack.h in order to accomplish the extra credit task, if you choose to do it. However, you are welcome to modify these files if desired during the coding and debugging process. You must write three files: Card.cpp, Hand.cpp, and Blackjack.cpp, which will contain all of the member function implementations that you’ve written. My suggestion is that you perform tasks in the following order: 1. Write implementations for the Card member functions, and write a small main-card.cpp file to test this class alone. Do not proceed to step 2 until Card class is working. 2. Write implementations for the Hand member functions, and write a small main-hand.cpp file to test class Hand and Card. 3. Finally, write implementations for the Blackjack member functions.

More products