Comp 212 Project 1
Hangman

Due Monday Feb. 28, 2000 10:00 AM.

This programming project is designed to make use of linear recursive structures.   It also serves as an example of how to write Graphical User Interface (GUI) programs using the Model-View-Controller (MVC) pattern.

Hangman

You are to write a Java GUI application that allows you to play the game of hangman.   The GUI should have the following features:

1.  A component for you to enter a word as a string of characters and display it as a series of underscores ("_").

2. A component for the program to draw the various parts of a body.

3.  A component for you to enter a character as a guess and obtain a response from the program.  If your guess does not match any character in the original word, one part of the body will be drawn.  If there is a match, the character will fill the appropriate underscores (displayed in item 1).  The games ends when there is no more body parts to draw, in which case you lose, or when all the underscores are replaced by the actual characters in the word, in which case you win.

4. A component for you to reset the game and start over.

You are required to implement the program in accordance with the following design specifications.

Design Details

The underlining data model should consist of the following linear recursive structures.

  1. An abstract AWord class to represent the input word.  An AWord can be empty or non-empty. When it is empty it contains nothing. When it is non-empty, it contains a character and another AWord. The characters in a non-empty AWord can be hidden or visible. When it is hidden, its String representation is "_". When it is visible, its String representation is the String representation of the character itself.  AWord should have enough intelligence to interact with the rest of the system as decribed below.
  2. A mutable list of body parts.  A BodyPartList can be empty or non-empty. When it is empty it contains nothing. When it is not empty, it contains a BodyPart object and another BodyPartList called the tail sublist.  BodyPartList should have enough intelligence to interact with the rest of the system as decribed below.

Your program should contain a concrete instance of an AWord, one BodyPartList object containing the body parts that are not yet drawn, and one BodyPartList object containing the body parts that are being drawn.  These objects and their supporting casts should not know anything about their views displayed in the GUI object.  Likewise, the GUI object should not know anything about the data model that it is displaying.  The GUI object should expose appropriate GUI components so that a separate controller object can attach various event listener objects in order to interact with the data model. 

The data model objects and the GUI interact with one another roughly in the following manner.  When a string is entered, an AWord representing this input string is created and displayed as a series of underscores.  When the user enter a guess character, this AWord will be asked to see if there is a match and if it is a winner.  If there is a match, the character will replace the  underscores in the appropriate positions.   If there is no match, a body part will be removed from the available part list, added to the drawing list, which then draws itself on the appropriate GUI component.   An AWord is a winner if all the underscores are replaced by the actual characters.   Activating the reset component will cause everything to re-initialize so that the game can start over again.

Submission

The project is broken up into three milestones.  Each milestone is to be submitted electronically.  You can use slack days on this project.  You are given a total of five slack days for the whole semester. Specific submission instructions will be posted on the Comp212 web page.  The complete milestone set should contain the following:

Milestone #1: due Feb. 14, 2000, at 10:00 AM - a GUI application testing the AWord class.  25% of project grade

Milestone #2: due Feb. 21, 2000, at 10:00 AM - a GUI application testing the BodyList class. 30% of project grade

Milestone #3: due Feb. 28, 2000, at 10:00 AM - the final GUI game application. 45% of project grade


alc@cs.rice.edu  dxnguyen@cs.rice.edu         Please let us know of any broken links             Revised Feb 07, 2000