Due date: Thursday September 30, 1999 at 11:59 pm
For this assignment, you are to write a program that will allow the user to play the game of blackjack against a computer dealer. The game of blackjack uses a standard deck of 52 playing cards. The deck contains 4 suits: clubs, diamonds, hearts and spades. Each suit contains 13 cards: ace, two, three, four, five, six, seven, eight, nine, ten, jack queen and king.
The goal of the game is get a collection of cards, called a "hand", that has a point total as close to 21 points as possible without going over 21 points. If a player goes over 21 points, they immediate lose (the player "busts"). In order to win, the player cannot "bust" and must have more points than the dealer (the dealer can also bust, in which case the player wins if they have 21 or less points).
The cards from two to ten are worth the same number of points as the card's name (a seven is worth 7 points). The cards jack, queen and king are worth 10 points. An ace is worth either 1 or 11 points. An ace is considered to be worth 11 points unless this causes the point total to be over 21, then an ace is worth 1 point. The suits have no impact on the points of the game, but every card must have an associate suit.
The basic play of each round is as follows:
For each hand in blackjack, the player makes a bet. This bet is against the dealer's hand only, not against any other player's hands. If the player loses the hand (the dealer wins), the player loses the bet. If the player and dealer push (tie), the bet is returned to the player with no extra winnings. If the player has a blackjack, the bet is returned to the player with a 150% winning (rounded down if needed). If the player wins without a blackjack, the bet is returned to the player with a 100% winning. In this game we will use "credits" as the unit of the bet. A player has to bet at least one credit per hand and cannot bet more credits than they have. The player will start the game with 500 credits.
Your program is to allow the following additional rules for the player.
To split a hand, the first two cards in the hand must have the same point value. The player is now playing two different hands instead of just one, where the first card of new hands is one of the cards from the original hand. The amount bet on the new hands is the same as the bet on the original one, and the player must have enough credits available to split the hand. Each hand is played independently. After the split, the dealer will deal a second card to the first hand and the player will play that hand until they stand or bust, then the dealer will deal a second card to the second hand and the player will then play that hand until the stand or bust. If the second card given after the split again matches the first card, the player may split again. Thus a player could end up playing 3 or more hands in a single round. Note: if a player splits two aces and gets a card worth ten points with one of the split aces, this is NOT a blackjack. Blackjack only occurs if the first two cards dealt to the PLAYER total 21 points, not if the first two cards dealt to a HAND total 21 points. A player is not required to split a hand and once the first hit is taken on a hand, that hand can not be split.
To double down, the first two cards in the hand must value a point value of 9, 10 or 11. If the player decides to double down, the bet amount is doubled and the hand only get one more card (for a total of three cards in the hand). A player may double down after a hand has been split. A player is not required to double down and once the first hit is taken on a hand, that hand can not be doubled down.
For more information on the game of blackjack, surf the web. There is a good page at www.blackjackinfo.com/bjrules.htm. This page also discusses how to play in a casino and includes other rules that we will not include in our program. There are also a number of gui-based blackjack games on the web. If you are unsure how to play, find one and learn how.
For this program, you MUST use classes for all user defined data types except for enumerated types. You must have at least three classes: card, shoe and hand.
Your program is to be interactive with a command interface. There will be two types of commands: inter-round commands (commands used between rounds) and intra-round commands (commands used during a round). The inter-round commands are:
Enter command for player hand 1 (h, s, d, ?) >This prompt indicates the player could hit, stand, double down or request help, but the player could not split the current hand.
Prior to each intra-round command, you are to show all of the cards in play (in some organized manner) and the point value for the current hand. The face and suit value of the dealer's first card is not shown to player until the end of the hand. So some way of indicating that this card exists but values are not being shown must be determined. At the end of each round, the following must be shown:
Your program must be written in good programming style. This includes (but is not limited to) meaningful identifier names, a file header at the beginning of each source code file, a function header at the beginning of the function, proper use of blank lines and indentation to aide in the reading of your code, explanatory "value-added" in-line comments, etc.
The work you turn in must be 100% your own. You are not allowed to share code with any other person (inside this class or not). You may discuss the project with other persons; however, you may not show any code you write to another person nor may you look at any other person's written code.
You are also to write a one to two page program description. This write up must be submitted with your program and be in ASCII text format. This description is to explain your internal data structures, code structures and the algorithms used in your program. Remember, this program description will be read by another student when the critiques are done for this assignment. Often the title of "readme" is used for these types of documents.
You are to submit this project using the EECS Department's UNIX machine's turnin command. The project name for this assignment is mp2. Be sure to submit all source code and header files as well as your makefile and program description. Failure to turnin all required pieces will result in a lower grade for the assignment.