CSC 313: Data Structures in Java
Autumn 2002
Individual Assignment 2
Designing and Implementing a Collection Class: The Poker Hand
Due Wednesday October 2 before 11:30pm
Create a class called PokerHand that simulates a five-card poker hand
using the Card class (online specification). You are to design the
class, but it must provide methods to accomplish the following:
- Provide a means for setting the hand's cards (either through the
constructor or through methods).
- Indicate the kind of hand (e.g. Full House, Straight, Flush, etc.)
- Compare this hand with a hand that is passed through a parameter and
report which hand is higher ranked.
Descriptions of the different kinds of poker hands and their relative
ranks can be found online.
Your code should have the following:
- The class should contain a sequence of test code in the main
method.
- The class should be fully documented with javadoc-style comments
so that you can create the specification file in HTML format.
- To simplify the class, you may assume that Aces are always ranked
as the high card (i.e. their rank is always 14). Also,
- Also to simplify your class, your code may rank hands of the same
type as equal. For example, a hand with 4 Kings is equal to a hand
with 4 Tens.
Here is some advice for designing and implementing your class:
- Start by only checking for simple hands and then incrementally add
the ability to check for more complex hands. For example, it is
relatively easy to check if a hand is a flush. A working program that
fails to check for certain kinds of hands will still receive a
significant amount of partial credit.
- Take a look at the DeckOfCards
class for an example collection class that holds cards.
- It is easier to check for pairs and straights if the hand is
sorted by rank.
Submission
Before the due date and time, you should submit the following three
files through the submission
Web page:
- Your individual version of PokerHand.java
- The specification file PokerHand.html that was created from javadoc.
- The file output.txt containing the output of your program's
test code.