Final Project - UMBC-CMSC104/General GitHub Wiki
Instead of having a final exam, instead we'll have a final project. Your project will be implementing Blackjack. Please name your source file blackjack.c. If you need more than just one source file, name them intelligently. It is due by 12/18/2012, the last day of finals.
The Game
Blackjack is a card game where players play against a dealer. Cards are worth a certain number of points (the face value of the card, or 10 points for a jack/queen/king). After receiving two cards, players attempt to get as close to 21 points as they can without going over by drawing cards (called a hit). The dealer also draws cards similarly. When a player stops drawing cards, they stand. Whoever has the higher point value after both players stand is the winner. If a player goes over 21 points, they automatically lose. This is called going bust.
The Deck
Here's the deck you should use:
int deck[] = { 2, 46, 45, 26, 11, 25, 16, 31, 24, 32, 35, 6, 17,
19, 38, 1, 33, 44, 52, 39, 47, 49, 23, 27, 37, 15,
4, 12, 21, 10, 50, 51, 14, 7, 3, 13, 9, 20, 5,
41, 40, 43, 18, 28, 42, 36, 34, 8, 29, 30, 48, 22}
- Numbers 1-13 represent Spades.
- Numbers 14-26 represent Hearts.
- Numbers 27-39 represent Diamonds.
- Numbers 40-52 represent Clubs.
Here's a table breakdown. Cards are listed along the top, and the suit is listed in the leftmost column. The numbers in each cell correspond to each card.
Suit | Ace | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Jack | Queen | King |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Spades | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
Hearts | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
Diamonds | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
Clubs | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
For example:
- 18 is 5 of Hearts.
- 51 is Queen of Clubs.
IMPORTANT: There are functions here that help with printing out the card information and obtaining points. There are three functions, get_suite, get_face_value, and get_num_points that are all demonstrated in this file. You can use these functions.
Playing
Drawing
Each time the user plays, he or she will draw from the deck, which will draw the top most card. Each subsequent draw will draw the next card. For example, drawing the first 3 cards from the deck:
- 2 (2 of Spades)
- 46 (7 of Clubs)
- 45 (6 of Clubs)
Simplifying Assumptions
- We'll assume that the Ace is always worth 1 point.
- We'll assume the dealer plays by the same rules as the player.
- The dealer will be player controlled.
- All cards are dealt face up -- that is, you can see the dealer's hand.
Some sample output
Welcome to Blackjack!
Would you like to play? (y/n) y
The dealer hands you two cards:
2 of Spades
7 of Clubs
You currently have 9 points.
The dealer takes two cards:
6 of Clubs
King of Hearts
The dealer has 16 points.
Would you like to hit? (y/n) y
You receive a Jack of Spades.
You currently have 20 points.
Should the dealer hit? (y/n) y
The dealer receives a Queen of Hearts.
The dealer has 26 points. Bust! You win!
Play again? (y/n)
Extra credit opportunities
- Add the ability to have more than one player.
- Shuffle your own deck.
- Exceptionally well designed code (proper use of functions).
Submitting
To submit:
submit cs104_wilson final blackjack.c
If you have more files to submit:
submit cs104_wilson final blackjack.c extra_file1.c extra_file2.c