Comp 212 Project 1
Hangman

Due Monday Oct. 23, 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 GUI component for you to enter a word as a string of characters and display it as a series of underscores ("_").

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

3.  A GUI 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 GUI 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 (see lab 04) 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 described 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 described 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.  Specific submission instructions will be posted on the Comp212 web page.  The complete milestone set should contain the following:

Milestone #1: due Monday Oct. 2, 2000, at 10:00 AM - Implementation of AWord, its subclasses and their supporting classes (see lab 04).  Write your own client to test your system. The test client need not be a GUI application. Instead of writing a client program, you may add a main method to AWord and/or WordChar to test them. You are free to reuse/modify the code we provide you, implement your own design using your own classes (for example, apply the visitor pattern to AWord), as long as you adhere to the general program requirements.  25% of project grade

Milestone #2: due Wednesday Oct. 11, 2000, at 10:00 AM - a GUI application testing the BodyPartList class.  You will be given some sample GUI code and are free to implement your own design using your own classes, as long as you adhere to the general program requirements.  30% of project grade

Milestone #3: due Monday Oct. 23, 2000, at 10:00 AM - the final GUI game application. This is the part where you are to assemble what you have done in the previous two milestone into a finished product.  It will take some design and some coding to connect everything together.  45% of project grade


dxnguyen@cs.rice.edu         Please let us know of any broken links             Revised Sept. 28, 2000