Executive Summary

You will implement a fully functioning game of Blackjack. No prior knowledge of the game is needed. However, you will need to know what cards appear in a standard deck of playing cards. See your instructor if you have any questions on that account.

Blackjack (also called "21") is basically a game between an individual player and a dealer. There's a gambling side to the game that this project does not address. The project simply plays the game with the user as "Player" and program as "Dealer", and determines the winner and loser.

Honor: The course policy and the instructions it references, most pertinently COMPSCIDEPTINST 1531.1C, spell out what kinds of assistance are permissable for programming projects. The instructor can give explicit permission for things that would otherwise not be allowed. For this project, you have explicit permission
  1. to get help from the other current IC210 instructor as well as your own (any assistance must be documented though), and
  2. to use general purpose C++ resources online (though such use must be documented). Resources that might specifically address this project, say looking through code of programs that do interest calculations, are not allowed.
Put the instructions referenced in the course policy and the explicit permissions above, and what you get is summarized as:

Part 1 [Up to 15pts]

~/$ ./part1
 2♣
 3♣
 4♣
 5♣
 6♣
 7♣
 8♣
 9♣
10♣
 J♣
 Q♣
 K♣
 A♣
 2♦
 3♦
 ⋮
A part 1 solution prints out a list of all 52 cards as shown to the right. Note that a correct solution must store representations of the 52 cards in an array, and then print the output. Otherwise its use in working towards the remaining steps of the project is limited.

Part 2 [Up to 30pts]

A part 2 solution should be exactly like the part 1 solution except that the cards will be shuffled. I'm going to specify what needs to be done to shuffle sufficiently very precisely: the following step will be done 200 times:
  1. choose two random positions in the card deck (note: it may happen that the two positions are the same, and that's OK)
  2. swap the cards at the two random positions (note that if the two positions are the same, this doesn't change your deck at all, and that's OK)
Make sure that all the cards appear in the shuffled output, and make sure that each time you run the program (assuming at least a second has passed) you get a different shuffle.

Part 3 [Up to 50pts]

~/$ ./part3
Player   Dealer
  2♠       A♦
  6♦       A♣

Player   Dealer
  2♠       A♦
  6♦       A♣
  J♥       3♣

Player   Dealer
  2♠       A♦
  6♦       A♣
  J♥       3♣
  8♣       3♥

Player   Dealer
  2♠       A♦
  6♦       A♣
  J♥       3♣
  8♣       3♥
  4♥       6♥
A correct part 3 solution will simulate dealing cards to a "Player" and a "Dealer" in the following order: deal two cards to "Player", two cards to "Dealer, then display (as shown on right). Then three rounds of dealing one card each to "Player" and "Dealer", then displaying the hands (once again as shown on right).

Part 4 [Up to 70pts]

A correct part 4 solution will start to play something that actually looks like a game. Player and Dealer will both be dealt two cards (as in part 3). But then the program will proceed to ask the Player and Dealer in turns whether they want to "hit" (in which case they get dealt another card into their hand), or to "stand" in which case their hand stays the same. The player goes first, and the program should go through three rounds (i.e. the Player and the Dealer both get three turns). In between rounds (i.e. just before printing out the current hands), make the call system("clear"); to clear the terminal window, so that only the current state of the game is showing at any given time. Below is an example of how a game might play out. Your output and the way you get input from the user should match what's shown here.
$ ./part4
Player   Dealer
  A♠       J♠
  2♣       Q♠
Player: (h)it or (s)tand? h
Player   Dealer
  A♠       J♠
  2♣       Q♠
  7♦         
Dealer: (h)it or (s)tand? s
Player   Dealer
  A♠       J♠
  2♣       Q♠
  7♦         
Player: (h)it or (s)tand? s
Player   Dealer
  A♠       J♠
  2♣       Q♠
  7♦         
Dealer: (h)it or (s)tand? h
Player   Dealer
  A♠       J♠
  2♣       Q♠
  7♦       4♦
Player: (h)it or (s)tand? s
Player   Dealer
  A♠       J♠
  2♣       Q♠
  7♦       4♦
Dealer: (h)it or (s)tand? h
Player   Dealer
  A♠       J♠
  2♣       Q♠
  7♦       4♦
          10♥

Part 5 [Up to 85pts]

A correct part 5 solution should behave exactly like a correct part 4 solution, except that in each round the current "best scores" for both Player and Dealer hands should be shown. The "best score" for a hand is computed according to the following rules. Add up points for each card in the hand, where aces are worth one point, kings, queens and jacks are worth 10 points, and numbered cards (i.e. 2 though 10) are worth their number in points. Call this number total. If the hand has no aces, total is the "best score" for the hand. If there are aces in the hand, and total + 10 is not greater than 21, the "best score" is total + 10. Otherwise, "best score" is simply total.
$ ./part5Player   Dealer
  9♣       6♦
  8♣      10♣
Player: 17, Dealer: 16
Player: (h)it or (s)tand? s
Player   Dealer
  9♣       6♦
  8♣      10♣
Player: 17, Dealer: 16
Dealer: (h)it or (s)tand? h
Player   Dealer
  9♣       6♦
  8♣      10♣
           3♦
Player: 17, Dealer: 19
Player: (h)it or (s)tand? h
Player   Dealer
  9♣       6♦
  8♣      10♣
  A♣       3♦
Player: 18, Dealer: 19
Dealer: (h)it or (s)tand? s
Player   Dealer
  9♣       6♦
  8♣      10♣
  A♣       3♦
Player: 18, Dealer: 19
Player: (h)it or (s)tand? h
Player   Dealer
  9♣       6♦
  8♣      10♣
  A♣       3♦
  7♠         
Player: 25, Dealer: 19
Dealer: (h)it or (s)tand? s
Player   Dealer
  9♣       6♦
  8♣      10♣
  A♣       3♦
  7♠         
Player: 25, Dealer: 19

Part 6 [Up to 95pts]

A part 6 solution functions just like a part 5 solution with the following two exceptions:
$ ./part6Player   Dealer
  3♣       3♦
  4♥       4♦
Player: 7, Dealer: 7
Player: (h)it or (s)tand? h
Player   Dealer
  3♣       3♦
  4♥       4♦
  8♥         
Player: 15, Dealer: 7
Dealer: (h)it or (s)tand? h
Player   Dealer
  3♣       3♦
  4♥       4♦
  8♥       9♦
Player: 15, Dealer: 16
Player: (h)it or (s)tand? h
Player   Dealer
  3♣       3♦
  4♥       4♦
  8♥       9♦
  8♣         
Player: 23, Dealer: 16
$ ./part6
Player   Dealer
  Q♣      10♠
  Q♠      10♣
Player: 20, Dealer: 20
Player: (h)it or (s)tand? s
Player   Dealer
  Q♣      10♠
  Q♠      10♣
Player: 20, Dealer: 20
Dealer: (h)it or (s)tand? s
Player   Dealer
  Q♣      10♠
  Q♠      10♣
Player: 20, Dealer: 20
$ ./part6Player   Dealer
  K♥       4♠
  A♥       5♣
Player: 21, Dealer: 9
Player: (h)it or (s)tand? s
Player   Dealer
  K♥       4♠
  A♥       5♣
Player: 21, Dealer: 9
Dealer: (h)it or (s)tand? h
Player   Dealer
  K♥       4♠
  A♥       5♣
           3♦
Player: 21, Dealer: 12
Player: (h)it or (s)tand? s
Player   Dealer
  K♥       4♠
  A♥       5♣
           3♦
Player: 21, Dealer: 12
Dealer: (h)it or (s)tand? h
Player   Dealer
  K♥       4♠
  A♥       5♣
           3♦
           2♥
Player: 21, Dealer: 14
Player: (h)it or (s)tand? s
Player   Dealer
  K♥       4♠
  A♥       5♣
           3♦
           2♥
Player: 21, Dealer: 14
Dealer: (h)it or (s)tand? h
Player   Dealer
  K♥       4♠
  A♥       5♣
           3♦
           2♥
           7♥
Player: 21, Dealer: 21

Part 7 [Up to 100pts]

A part 7 solution functions like a part 6 solution with the following modifications:

Extra Credit [Up to 110pts]

An extra credit should be e-mailed to your instructor, while a Full credit Part 7 solution is also submitted as described below. The extra credit solution will not even be considered unless the Part 7 Full credit solution functions correctly.

Your extra credit solution should play the game over and over again. Each time the player finishes a game, the program should ask whether the player wants to play again or quit. Each play the player must make a $5 bet. If the player wins, the player gets the bet plus some amount of winnings back. You may decide what the payouts are (could be as siumple getting your bet plus $5 back). You must report the players winnings / losses at the end of each round. The player must have the option of withdrawing from a game (not the table, just that game) after the initial two cards are dealt to player and dealer, but before any other play has taken place. Withdrawing means half the bet is returned to the player, but the other half goes to the house.


When to submit

Project 2 is due by COB on Monday, October 27th, according to the course's particular definition of "COB". Late projects incurr a penalty of 3N points, where N is the number of days late. So, a project that is not turned in by COB Monday, 27 October, but which is turned in by COB Tuesday receives a 3 point penalty. A project that is not turned in by COB Tuesday, but which is turned in by COB Wednesday receives a 9 point penalty. And so on.

What to submit

You will submit the furthest properly functioning solution. So, if your Part 7 solution works, submit the Part 7 solution. If you don't have a properly functioning Part 7 solution, but your Part 6 solution works fine, submit a Part 6 solution. And so on. What gets submitted is:
  1. Your source code (i.e the .cpp file). You will submit a printout of this (use codeprint) and an electronic copy (how to do the electronic submission will be explained later).
  2. A completed copy of this coversheet on paper.

How to submit

The paper portions of your submission should be stapled together and slid under your prof's door. Instructions on electronic submission: Use the same method that was used in the first project. From the directory on your Virtual Machine where you have been saving your project, type:
submit proj02 *.cpp
This will submit all C++ files in that directory, with the goal of pushing the C++ file for each portion of the project. The syntax of the command is submit Project_Name (in this case proj02) and the files you wish to submit. Feel free to include any additional files you believe may be beneficial. You may submit files at any time, the last submission will be used for grading.

How projects are graded / how to maximize your points

Things to keep in mind to receive full marks:
  1. Submit all required items (as described above) on time.
  2. Make sure the form of your output matches the form of the example output in all ways. Of course the cards you see and decisions dealer and player make will vary from the examples you see.
  3. Make sure you follow the IC210 Style Guide. This means proper indentation, use of whitespace within lines of code, logical organization of chunks of code,
  4. Make sure you do a good job of putting things in functions. One monolithic main function is not OK, even if it works! The quality of your overall design will play a role, and a large part of that boils down to using functions well.
Most important: Look at the the grading sheet.