CS 112 - Introduction to Computer Science II
Homework #4


Due: At the beginning of class 12.  This work is to be done in pairs.  I strongly recommend the practice of Pair Programming described simply here.  Although team members are permitted to divide work, each team member should be able to informally present all work of his/her teammate.  Much groundwork will be laid in class.

1.  Text-based FreeCell: The solitaire card game of FreeCell is an interesting random-generated puzzle that is solvable with high probability.  According to the FreeCell FAQ: "A large-scale computerized statistical study, conducted by Don Woods, analyzed a million random deals. Woods reported to the Usenet group rec.games.playing-cards that the program had solved all but 14 of them, making the win rate for FreeCell almost 99.999% ... ."

However, beyond being an excellent solitaire card game, FreeCell can serve as an illustration for object-oriented design.  To solve a complex problem, one prototyping technique is to abstract the problem by dropping contraints.  Doing so can suggest intermediate "stepping stones" or "milestones" for an elaborative development plan.  For example, one may approach the implementation of FreeCell in a bottom-up fashion, beginning by modeling a card and a card stack.  There are three types of card stacks: the cell (at most one card), the foundation (ascending ranks of a single suit starting at Ace; cannot be played from), and the cascade (cards placed on top must alternate colors by descending ranks).  However, before implementing the full complexity of the constraints, one might form the intermediate implementation goal of dropping restrictions for card plays, treating each type of card stack as a generic card stack and getting the basic card play mechanism correct before introducing the constraints for each stack type.  This will be our approach.

For this assignment, you will implement a text based FreeCell according to this Javadoc specification.  (Name your classes and their members accordingly.)  This transcript (input, output) shows the desired input, output specification (minus simple error messages: "Illegal stack number.", "Illegal play.") for game seed 0.  (This assumes that you implemented the Deck.java Knuth / Fisher-Yates shuffle algorithm and Card.java card ordering exactly as shown in class.) 

Rubric: (20 points total)