Program 3: BlackJack Solitaire Simulation
Purpose
The purpose of this assignment is to design and implement a
Java program that simulates a solitaire version of
BlackJack.
Partners
You may (and are encouraged to) work with at most one other
partner on this assignment. You and your partner must
be in the same lab section. If you work
with a partner, submit one solution with both of your names on it.
Assignment
Create a BlueJ project named Program3 and place
the following files in it:
Your task is to modify the CardDeck and Card classes
such that a solitaire version of BlackJack (described below)
can be simulated. The BlackJack class should be left
alone and not modified.
BlackJack Solitaire Background
Before the simulation is begun, the user will be asked
to supply a lower bound between 1 and 21. Call this
value lowerBound.
Each time a game is simulated, the following steps
should occur:
- Shuffle a regular, 52 card deck of cards.
- Deal the cards one at a time. If the total
value of the cards dealt is ever greater than or equal
to lowerBound and less than or equal to 21, the
game is won. If the total value of the cards
dealt ever exceeds 21, the game is lost.
In BlackJack, the value of a card is as follows:
- A two is worth 2 points.
- A three is worth 3 points.
- A four is worth 4 points.
- A five is worth 5 points.
- A six is worth 6 points.
- A seven is worth 7 points.
- An eight is worth 8 points.
- A nine is worth 9 points.
- A ten is worth 10 points.
- A jack is worth 10 points.
- A queen is worth 10 points.
- A king is worth 10 points.
- The first ace in the hand is worth 11 points, unless this
ever makes the total value of the hand exceed 21 points. In
this case, the first ace should be reevaluated to be worth 1 point.
All subsequent aces are worth 1 point.
Getting Started
The three files that you are given will compile and run. Make sure
that you understand them well before beginning. Notice that the
CardDeck class contains the following methods that currently
do nothing:
- initializeSimulation - the method should initialize
appropriate instance variables before the BlackJack
simulation begins.
- simulateBlackJack - the method should simulate one game
of BlackJack solitaire and record whether the game
was won or lost.
- getWins - the method should return the total number of times
that BlackJack solitaire was won.
- getLosses - the method should return the total number of times
that BlackJack solitaire was lost.
Grading (50 points possible)
- 5 points - the simulation works correctly for the range [1, 21].
- 5 points - the simulation works correctly for the range [11, 21].
- 5 points - the simulation works correctly for the range [17, 21].
- 5 points - the simulation works correctly for the range [18, 21].
- 5 points - the simulation works correctly for the range [19, 21].
- 5 points - the simulation works correctly for the range [20, 21].
- 5 points - the simulation works correctly for the range [21, 21].
- 5 points - CardDeck.java and Card.java contain appropriate comments,
javadoc and otherwise.
- 5 points - the code that performs the simulation is reasonably efficient.
- 5 points - the code in CardDeck.java and Card.java is understandable
and well written.
Submission
E-mail the CardDeck.java and Card.java
files as an attachment to your lab TA no
later than the start of your lab on Tuesday, October 28th.
Late submissions receive no credit, but partial credit can
be earned by making an ontime submission.
The subject of the e-mail should be CS 160, Program 3,
your name, your partner's name.