Blackjack

Basic Game Requirements

  • 1 deck of cards, shuffled after each hand.
  • The game will include 1 player and 1 dealer.
  • Cards should be distributed in the following fashion: player (face up), dealer (face up), player (face up), dealer (face down), [player], [player], [player], [dealer], [dealer], [dealer]. The cards in "[]" indicate optional cards based on whether or not the player or dealer hits. Both the player and dealer will receive a minimum and maximum of 2 and 5 cards respectively.
  • 5 card charlie will be used. If the player or dealer obtains 5 cards without busting, he automatically wins the hand.
  • Betting will be incorporated in this game and the player will start out with $500. The player should bet BEFORE the cards are dealt. The player minimum bet is $5 and the maximum bet is the total player amount. If the player dips below $5, the game is over. * Special features such as splitting, doubling-down, obtaining insurance, etc. will NOT be incorporated in this game, however, you may add these features later once you get the core functionality working.
  • After the initial two cards are dealt out, the player has the option to HIT (receive another card) or STAND (not receive another card and move control over to the dealer).
  • If the player BUSTS (goes over 21), the player automatically looses and we move onto the next hand.
  • Dealer hits on anything less than 17. Dealer will stand on anything 17 or higher. If one of the first two cards of the dealer is an Ace it will have the value of an 11. However, if the dealer is dealt two aces to begin, the hand value will be 12. If the dealers hand value goes over 21 and he has a hard Ace (value of 11), that Ace will be converted to a Soft Ace (value of 1).
  • If the player gets natural blackjack and dealer does not, then player automatically wins and gets 1.5 times their bet back. If the dealer gets a natural blackjack and the player does not, then the dealer automatically wins. If both the player and dealer have a natural blackjack, it is a push. A natural blackjack (21 with just two cards) is the only hand that pays out 1.5, even if the player or dealer wins with a total card count of 21 (with more than two cards).
  • Graphics is not required but encouraged.
  • Testing functionality should be incorporated in your program to allow you and your team to easily and quickly test several scenarios in your program. Considering all the possibilities involved in the game of Blackjack, testing under normal random card distribution would be extremely tedious and time consuming.You should have TWO drivers, one for normal game playing and another for tesitng your classes. See below for details on the testing requirements.

Example Game Play

Player has $500.00
Player BETS $10
Player gets 10S (card face up)
Dealer gets 5S (card face up)
Player gets 3S (card face up)
Dealer gets 10H (card face down)
Player has a total of 13 and dealer is showing a 5.
Player decides to HIT.
Player gets 3C, bringing his total to 16.
Player decides to STAND.
Dealer shows his face down card. His total is 15 so he must HIT.
Dealer gets a 2D, bringing his total to 17. The dealer STANDS and WINS.
Player has $490.00

Testing Information

Your project should include a driver for testing purposes along with a text file called "test.in" which can hold testing scenarios. Here is an example of what the text file may look like:

#1 - Test 2-Card Player Win (19-17) - Player wins $10
10, p09H, d12S, p10C, d07S
#2 - Test 2-Card Dealer Win (20-15) - Dealer wins
10, p10H, d10D, p05H, d11C
#3 - Test 2-Card Push (18-18) - Push
10, p10H, d10D, p08H, d08D
#4 - Test 2-Card Player Win Blackjack (21-18) - Player wins $15
10, p12D, d08H, p01S, d11D
#5 - Test 2-Card Dealer Win Blackjack (21-16) - Dealer wins
10, p10H, d13D, p06S, d01H
#6 - Test 2-Card Push with Blackjack (21-21) - Push
10, p12H, d11D, p01D, d01S
#7 - Test 3-Card Player Win (20-18) - Player wins $10
10, p05h, d10h, p07s, d08d, p08s
#8 - Test 4-Card Dealer Win (19-17) - Dealer wins
10, p10h, d02h, p07d, d05d, d02s, d10d
#9 - Test 5-Card Player Win, 5-Card Charlie (21-17) - Player wins $20
20, p02h, d10h, p02d, d07d, p03h, p10d, p04d
#10 - Test 3-Card Player Bust (25-18) - Dealer wins
10, p10h, d10s, p05d, d08h, p10d

The first line indicates the testing number ("#1") along with a test case description ("Test Player Bust"). The second line indicates the bet amount (10) and the cards to be dealt out (Player gets 9 of Hearts, Dealer gets 12 of Spades, Player gets 5 of Clubs, Dealer gets 7 of Spades, Player gets 10 of Diamonds). The order will always be player, dealer, player, dealer. Thereafter, the player may hit 0 to 3 times followed by the dealer who may hit 0 to 3 times. Additional test case scenarios can follow as desired.

The testing functionality should read from "test.in" to test the scenarios listed in the file and then output the results to a file called "test.out". Below is an example of what the output file may look like:

#1-Player-10
#2-Dealer
#3-Push
#4-Player-15
#5-Dealer
#6-Push
#7-Player-10
#8-Dealer
#9-Player-20
#10-Dealer

The format of each line is the testing number (e.g. "#1"), a '-', the winner (e.g. "Player" or "Dealer" or "Push"), and in the case of a player win, a '-' and the winnings (e.g. "10"). The output should be formatted EXACTLY as shown above since your project will be graded, in part, by the number of test cases passed and test cases only pass if your output matches the expected output exactly.

As a quick refresher, here is sample code that demonstrates how to read/write from/to a file.

//Writing Example
PrintWriter pw = new PrintWriter(new FileWriter("test.out"));
pw.println("Hello World");
pw.close();
 
//Reading Example
Scanner in = new Scanner(new FileReader("test.in"));
 
while(in.hasNextLine())
{
    String s = in.nextLine();
    . . .
}
 
reader.close();

Design Requirements

Your Blackjack Designs should include the following:

  • Cover page with the date and team member names,
  • One to two pages explaining the rules of blackjack which are specific to the functionality of your game.
  • A walk-through that explains the execution of the game from start to finish. You should include screen shots in the walk-through to facilitate understanding. All aspects of the game should be addressed here, leaving no question as to how various conditions will be handled. This will require multiple pages.
  • A page that includes a UML diagram from Violet. This diagram should show all the classes along with their respective instance fields and methods.
  • On the last page, you should list the following: a) how you plan on dividing the workload of the project (if you are working on a team), b) any questions/concerns you have regarding how to implement the project.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License