Introduction to Programming (CPSC 124)
—Hobart & William Smith Colleges, Fall 2014
Project #7
Home | Syllabus | Calendar | Class Notes | Labs and Projects | General Notes

Due by 5:00 pm on Tuesday, 11/25/2014

Draw Poker

This assignment involves a number of classes designed to implement a program for playing draw poker, the most commonly-played form of poker. There are several classes you'll need to download before starting:

Your Job

These classes are slightly modified versions of those given in Section 5.4 of our text. In this assignment, you will extend the Hand class with two methods:

The possible kinds of poker hands (ordered from highest to lowest) are: Royal Flush, Straight Flush, Four Of A Kind, Full House, Flush, Straight, Three Of A Kind, Two Pair, Two Of A Kind, and High Card. In the event of a tie, the rules for determining the winner can be subtle, involving comparisons of suits (clubs, diamonds, hearts, spades, from lowest to highest), ranks, and/or the high card begin held. To simplify this part of the problem, you can just break ties on the value of the high card in each hand (you're certainly encouraged to implement the full comparison rules if you want, but a high-card tiebreaker is enough).

Getting Started

Download the four class files above. All of them must be saved in a folder named playingcards (i.e. the package name ). Try to compile The attempt will fail, since the Hand class does not yet have an implementation of compareTo(). Build a prototype version of that function (for example, the body could be "return 1;"), and add a prototype toString() method. You should be able to build everything now.

To run it from the command line, you'll have to change to the parent folder of playingcards. From there, invoke the JRE on the fully package-qualified name:

John-Lasseter:code jlasseter$ java playingcards.DrawPokerMain

You will probably need to implement several private test methods for this task. For example,

private boolean isTwoOfAKind() {
   Card c =[0];

   for (int i = 1; i < this.count; i++) {
       if ([i].rank == c.rank) {
           return true;
       } else {
           c =[i];
   return false;

private boolean isThreeOfAKind() { ... }

and so on.

Standards (READ ME)

Formatting Requirements

See the Style Guide, available from the General Notes section of our course web site. Beginning with this assignment, all elements of beautiful, clear code style described there will be expected.


Turn In

John H. E. Lasseter