Comp 212 Spring 2001, Project 1: Hangman

Due Friday 16 Mar. 2001 11:59 PM.

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. (MVC will be discussed in upcoming classes and lab, in time for you to use it.)


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

The details of how the GUI displays these components is up to you. The choice of how many and which body parts to use is up to you.

Design Details

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

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

These should also have whatever fields and methods needed to support the following requirements.

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 enters 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.


The project is broken up into three milestones, each to be submitted electronically. Each should contain


  1. Due Monday 19 Feb. 2001, at 11:59 PM, 25% of project grade. 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 and modify the code we provide you or implement your own design using your own classes (e.g., apply the visitor pattern to AWord), as long as you adhere to the general program requirements.

    Turn in with project name hangman1.

  2. Due Wednesday 28 Feb. 2001, at 11:59 PM, 30% of project grade. 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.

    Turn in with project name hangman2.

  3. Due Friday 16 Mar. 2001, at 11:59 PM, 45% of project grade. The final GUI game application. This is the part where you are to assemble what you have done in the previous two parts into a finished product. It will take some design and some coding to connect everything together.

    Turn in with project name hangman3.