As in project 2, the work for this simulation is broken into two parts. The GUI interface is being written by another group of students. Your assignment is to implement the supporting classes discussed in class this week.
Designing this project will be an in-class student exercise based on the specification below. In class we will identify the classes necessary for the game and specify the required interface between these classes and the GUI. Note that as the GUI is developed this interface may change slightly if the GUI programmers discover that more public methods are required for a particular class.This project will use a GUI to allow the user to control the game and display pertinent information as the game progresses. The GUI and the main driver will be provided for you in Project3.java to be found in Mr. Frey's public directory for this project.
So that all students play the same game (i.e. the cards are dealt in the same order), it is necessary that the deck of cards be initialized appropriately before shuffling. Initialize the deck of cards in the order Ac, 2c, 3c, ..., Qc, Kc, Ad, 2d, ..., Qd, Kd, Ah, 2h, ..., Qh, Kh, As, 2s, ..., Qs, Ks .
The algorithm below which shuffles an array of integers must be adapted and implemented to shuffle the cards to start a new game. This algorithm is known as the Fisher-Yates algorithm, was first designed for computers by Richard Durstenfeld, and popularized by Donald Knuth.
nextInt( )
method of the random number
generator class Random
found in the Java library. To insure that all students get the same result after shuffling, seed the random number generator with the value 1234.
A directory named cards that contains card images to be used for this project can be found in Mr. Frey's public directory. Copy this directory into your Eclipse project so that the cards directory is at the same level as the src directory. The cards directory is also available in tar and zip formats.
Suit.java defines Suit objects used to identify a card. For example, Suit.HEARTS
is used to represent the suit "hearts".
This class is provided so that there is no possible discrepancy among all classes that refer to a card's suit. The four suits in a standard 52-card deck are Suit.HEARTS, Suit.SPADES, Suit.DIAMONDS
, and Suit.CLUBS
.
Do not submit Suit.java.
Documentation for Suit.java is provided in the file itself and in the
Suit API document
Rank.java defines Rank objects used to identify a card. For example, Rank.TWO
is used to represent a card with a rank of two. This class is provided so that there is no possible discrepancy among all classes that refer to a card's rank. The ranks of the cards in a standard 52-card deck are
Rank.ACE, Rank.TWO, Rank.THREE, ... Rank.JACK, Rank.QUEEN,
and Rank.KING
. Do not submit Rank.java.
Documentation for Rank.java is provided in the file itself and in the
Rank API document
proj3
.main
in each class to perform unit testing.
See Testing Your Class in Main for help writing main
to test your classes.You can check to see what files you have submitted by typing
Remember -- if you make any change to your program, no matter how insignificant it may seem, you should recompile and retest your program before submitting it. Even the smallest typo can cause compiler errors and a reduction in your grade.
Avoid unpleasant surprises!