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:
A GUI component for you to enter a word to be guessed. You enter it as a string of characters. Initially, it is displayed as a series of underscores ("_"), since none of its letters have been guessed yet.
A GUI component for the program to draw the various parts of a body.
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.
Note that guessing a character previously guessed produces the same behavior as the first guess. It either matches again or misses again.
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.
The underlining data model should consist of the following linear recursive structures:
An abstract AWord
class
(see lab 04) to represent
the input word. An AWord
can be
empty or non-empty.
AWord
.
AWord
can be hidden or visible.
String
representation is
underscore ("_").
String
representation is
that of the character itself.
A mutable list of body parts. A
BodyPartList
can be empty or non-empty.
BodyPart
object and another BodyPartList
.
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
All the Java source code necessary to compile and execute your test code.
Javadoc documentation of all the code.
A text README
file to indicate what you have and
have not done, and to point out specific details that you feel
we need to know when grading your work.
UML diagrams of all your class designs.
Milestones:
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
.
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
.
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
.