CMSC 132 -- Project 1
Due: Friday 2/11/05 at 11:00 PM
Texas Hold 'Em Simulator
This is a closed project. You are expected to do all of the work on this project without consulting with anyone other than the CMSC 132 instructors and TAs. Treat this project as though it were a take home exam. If you have any questions about whether or not a certain topic is okay to discuss with classmates or friends, please ask your instructor.
This project will simulate something close to a game of Texas Hold 'Em, which is a style of poker. If you don't know how to play this game (or if you've never played cards before in your life), don't worry -- we'll explain everything! Most of this program will be written for you. We will provide the graphical interface and most of the infrastructure for the project. You will supply two components: A method that will produce a shuffled deck of cards, and a method that takes 5 cards as input and determines what kind of poker hand it is.
To see what the finished product looks like, click the link below:
Click here to see the working project!
If you are not familiar with the standard deck of 52 playing cards and the terminology that goes along with it ("suit", "queen", "clubs", etc.), then please take a look at the Playing Card Page.
If you are not familiar with poker hands, such as "Full House" or "Straight Flush", then please read the Poker Hand Page. By the way, to successfully implement this project you need to know the definitions of these hands very precisely, so unless you are a real expert it would be a good idea to read this information carefully!
If you are not familiar with this game, then please read the Introduction to Texas Hold 'Em Page.
Most of this project has been completed for you. There are only two methods that you must write (described later).
The full project consists of the following classes:
Card.java -- a single playing card (provided for you)
DeckGenerator.java -- an abstract class used to create a shuffled deck (you will write most of it).
ImageLoader.java -- loads the .gif images of the cards from files (provided for you).
PokerGame.java -- This is both the "model" and the "controller" for our project. (provided for you).
PokerHandEvaluator.java -- determines the rankings of sets of cards (you will write most of it)
PokerJPanel.java -- the "view" for the project (provided for you).
An instance of this class represents one playing card. There are two fields that you will use:
public int suit -- 0, 1, 2, or 3. 0 represents Spades, 1 is Diamonds, 2 is Hearts, 3 is Clubs
public int value -- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13. 1 is "ace", 11 is "jack", 12 is "queen", 13 is "king". (The others are obvious.)
Take a look at the class to see what methods are available -- you will use Card objects when you write other portions of the project.
You must implement the following method:
public static List generateDeck()
The method must create a List containing the 52 distinct cards found in the standard deck. You may want to use the java library class ArrayList to represent the deck of cards. If you have not used this class for a while you should begin by reading the java API for the ArrayList class.
Important: The deck must be shuffled before it is returned! How you shuffle the deck is entirely up to you, but here is a hint: You might save time using a method that is part of the Collections class. If your deck is not randomly shuffled you will lose points!
You must implement the following method:
public static int evaluateFiveCardHand(Card  cards)
The parameter represents an array of five cards. (It will always be exactly 5 cards). Your method must rank the five card hand using the rankings described in the Poker Hands section. Don't forget that if more than one ranking applies, we always select the highest one.
The return value must be selected from the following table:
Straight Flush -- return 8
Four of a Kind -- return 7
Full House -- return 6
Flush -- return 5
Straight -- return 4
Three of a Kind -- return 3
Two Pair -- return 2
Pair -- return 1
Nothing (None of the above) -- return 0
Occasionally project updates or important notices need to be released after the project has been posted. These notifications will be posted on the class wiki. It is your responsibility to check the class wiki periodically for such notices.