|
Project #1 (Blackjack) |
CMSC 132 |
|
Due Date: Fri Feb 9, 6:00 pm |
Object-Oriented Programming
II |
|
Type of Project:
Open |
Spring 2007 |
Objective
This project will give you practice using ArrayList, and programs that use the MVC (Model-View-Controller) model of
interaction.
In case you have not already noticed, this is an Open assignment. You
must read the Open/Closed policy before working on this project. The
policy can be found at
policy.
Overview
For this project you will write a class named Blackjack that
implements the game logic associated with a blackjack card game. The Blackjack
class implements the BlackjackEngine Java interface whose definition you
can find in the project's javadoc documentation.
Grading:
-
Tests (75 %)
-
Public JUnit tests (40 %)
-
Release JUnit tests (25 %)
-
Secret JUnit tests (10 %)
-
Student Tests (10 %)
-
Style (15 %)
For this project:
-
Even if you are not planning to work on the project for a while make sure
that:
-
You can compile a simple class using the provided code distribution. If
you have problems compiling a simple class see your TA immediately.
-
Submit your project using the "Submit Project" option in Eclipse and
verify your submission has been received in the submit server. It is
important that you submit your project using the "Submit Project" option
rather than uploading a jar file to the submit server. If you are
having problems with this submission process, contact your TA or
instructor immediately.
-
You must debug your code using the Eclipse debugger and should not use "System.out.println"
as a debug tool. The TA in office hours will require you to use the
debugger to show any problems you are experiencing.
Code Distribution:
The project's code distribution is available by
checking out the project
named p1. The code distribution provides you with the following:
- A package called blackjackGUI - This package implements the game's
Graphical User Interface. You don't have to modify or add anything to
this package. We have provided the source code in case you are
interested to see how it works. In this package you will find a class
named PlayBlackjack which is the class you will execute if you want
to play the game through the GUI.
- A package named blackjack - In this package you will find the
shell for a class named Blackjack that implements the blackjack game
logic. This is the class you need to implement for this project.
In the blackjack package you will also find the following support classes:
Card, CardSuit, and CardValue. You will use these
classes during the implementation of the the Blackjack class; you should not
modify these classes.
- PublicTests.java - This class represents the set of JUnit public
tests. The expected results for each test can be found in the text files
with a "pub" prefix. This class can be found in the tests
package.
- A package named tests - Includes the public tests (PublicTests.java)
and a shell for a class (StudentTests.java) that you must complete
with your own tests.
Blackjack Rules
If you have been to Vegas then you are familiar with the rules to play
blackjack (also known as 21). However, what happens in Vegas stays in Vegas,
therefore the rules for blackjack in this project are different. If you want to
familiarize yourself with the game, check the online blackjack game available
at:
http://javaboutique.internet.com/BlackJack/index.html. Note that
the rules we will use are not exactly the same ones used in this online game.
In our blackjack version we have a dealer (person who shuffles and distribute
cards) and only one player. The game's objective is for the player to beat the
dealer by generating a hand of cards whose value is higher than the dealer's
hand without exceeding a total value of 21. The game starts by the dealer
shuffling cards (one or more decks) and dealing two cards to the player and
herself/himself (the actual order is described in the project's javadoc documentation). One of the dealer's cards will be face
down. At this point the player will ask for cards until he/she understand it
can beat the dealer with the current hand and as long the cards' total value
does not exceed 21. If the hand of cards does not exceed 21, and the player
stops requesting cards (what is refer to as "stand"), then the dealer will flip
the card that was face down, and proceed to deal cards to himself/herself as
long as the cards' value is less than 16 and does not exceed 21. If a value
greater than 21 is generated the player wins. Otherwise whoever (player or
dealer) has the hand with the highest value will win the game.
The following provides additional information about the game:
- The term "bust" refers to the scenario where the player or dealer cards'
value exceeds 21.
- The term "blackjack" refers to the scenario where in a hand of cards we
have an Ace("1") along with a "10", Jack, Queen, or King.
- In our blackjack version the player cannot split a hand of cards. If
you don't know what splitting is disregard this comment.
- The value of cards "2" through "10" correspond to the numeric value
associated with the card face value.
- "1" (Ace) could be worth either 1 or 11.
- The Jack ("J"), Queen("Q"), and King("K") are worth 10 points each.
- The card's suit (i.e., "SPADES", "DIAMONDS", "HEARTS", "CLUBS") has no
bearing on a card's value.
Requirements
Project Requirements
- The state of the game is defined by the values: BlackjackEngine.DEALER_WON,
BlackjackEngine.PLAYER_WON, and BlackjackEngine.GAME_IN_PROGRESS.
- Your program should handle more than one deck of cards.
- When creating a deck of cards, load the suits in the following order:
SPADES, DIAMONDS, HEARTS and CLUBS. At the same time, each suit should
be loaded starting with the ACE, followed by cards with a face value of "2"
through "10", followed by the "JACK", "QUEEN", and "KING".
- When creating more than one deck of cards, you must load one deck at
a time using the order specified above. After all the cards have been
loaded, then you can proceed to shuffle them. For instance, a game with 2 decks of cards is initially created as: Spade Ace, Spade 2, Spade 3,... Spade Jack, Spade Queen, Spade King, Diamond Ace ... Diamond King, Heart Ace ... Heart King, Club Ace ... Club King, Spade Ace ... Spade King, ... Club King
- You must use ArrayList objects to represent the player and dealer's
cards, and the deck.
- You must use the shuffle method of the java.util.Collections
class to perform the data shuffling. You must use the shuffle method
that takes a list followed by a Random object. Notice that the list
parameter is defined as List<?>. You can ignore that definition. The
method will work with ArrayList objects.
- A player has an account with an initial value of 200 chips.
- The default initial bet is 5 chips.
- When a new game is dealt the bet amount is deducted from the account.
- When a player wins he receives twice the bet amount.
- When a player draws he receives the original bet amount.
- Immediately after checking out the code distribution, make sure you can
submit your project, even if you have not implemented the project. Do
not wait until the day the project is due to submit your project for the
first time.
- Verify that your project passes the submit server tests (https://submit.cs.umd.edu/)
- You must provide your own tests in the file StudentTests.java
provided with the code distribution.
- Keep in mind that for this project you have three release tokens in the
submit server.
- Do not define any supporting classes.
Style Requirements
- You must avoid code duplication. For example, if several methods in
your class share the same code fragment, place the common fragment in a
private method.
- You must follow Java conventions for identifiers. For example,
class/interface names must start with capitals.
- You must use meaningful variable names.
- You must indent your code using three or four spaces or by using the
Eclipse "Correct Indentation" option.
- You must use the same style for blocks of curly brackets ({ })
throughout your code.
Honor Section Requirements
For those students in cmsc132H your project should satisfy all the
requirements specified above and in addition you should treat this project as a
closed project.
Submission
Submit your project using the submit project option associated with Eclipse.
Academic Integrity
Please make sure you read the academic integrity section of the syllabus so
you understand what is permissible in our programming projects. We want to
remind you that we check your project against other students' projects and any
case of academic dishonesty will be referred to the
University's Office of
Judicial Programs.