Program #1 is worth 75 points Assigned: Mon Jun 16, 2003 Due: Fri Jun 27, 2003
ConceptsIn this program, we will review concepts covered in CSC 160, including:
|
|||||||||||||||||||||||||
DescriptionImplement a program that plays Blackjack or "21". This card game has a "dealer" and one or more "players". The goal of the game is to get as close to a total of 21 with your cards, without going over that amount. En route to 21, each card has a value:
Step 1. Initial dealThe game starts with four cards being dealt: two to the player, two to the dealer. The player cards are dealt "face up", in other words, they are shown. Only one of the dealer's two cards is shown; the other is hidden from the player. Step 2. Player's turnThe player, based on his two cards and the dealer's showing card, can decide to add a card to his hand, called a "hit". He/she can stop at any time, by deciding to "stay". If the player's total exceeds 21, then he/she has "busted" and the turn ends. There is one special case. If the player's first two cards total 21, he/she has a "Blackjack" and is an automatic winner. This is only possible if one of the cards is an Ace and the other a card having a value of 10. With a Blackjack, the player is not offered the opportunity to "hit" because he/she has already won. Step 3. Dealer's turnIf the player does not have a Blackjack (an automatic winner) or has not busted (an automatic loser), then it is the dealer's turn. The dealer shows his hidden card, and then takes additional cards until they total 17 or higher. Three cases are possible at this point:
Example SessionHere's an example session, player responses in bold:
|
|||||||||||||||||||||||||
ImplementationThere are some sticky issues here:
|
|||||||||||||||||||||||||
GradingYour program will be graded on three areas: design, quality, and function Design (20%) For this object-oriented program, your design will be be represented by the class header files in your program. You should be able to compile your header and "stubs" for your member functions for this. We will discuss in class how to do this. Accompanying your design, you should complete a "halfway" checkpoint. On your k: drive, create a test program that 1) prints out all the cards in a deck in some order (by suit?) and 2) deals random cards off a deck. Quality (20%) Your code should be well-commented, properly indented and structured, and contain informative and consistent names. The purpose of each functions and its parameters should be well-commented at the top of the function. Function (60%) Your program must implement the program features per the description above. Place any comments you have in your README file. |
|||||||||||||||||||||||||
Notes/HintsBe as tangible as you can in defining your classes. Try it. To create a different random seed (by calling srand() once at the beginning of your program) each time you run your program, use this:
BTW, if you're unfamiliar with playing cards, there are 52 cards in a deck. There are 4 suits: Clubs, Diamonds, Hearts, and Spades. There are 13 cards of each suit: Ace, 2-9, Jack, Queen, and King. Don't forget a README file in your folder detailing your journey and your testing methodology. Additional fun things you can add to this program:
|