Assignment:
Hangman Game
Write a hangman program the allows one
person to enter a word to be guessed, and then clears the screen. Another person
can then guess the word by entering letters. In a text-based program, the output
might look similar to:
Enter word to be guessed: BANANA
(Screen clears)
Word is: _ _ _ _ _ _
Your letter ($ to guess word)? S
Sorry, there are no S's.
Your letter ($ to guess word)?
N
Word is: _ _ N _ N _
Your letter ($ to guess word)?
B
Word is: B _ N _ N _
Your letter ($ to guess word)?
S
Sorry, you guessed S already. Try again.
Your letter ($ to guess word)?
$
Your guess? BANANA
Correct! You took three tries.
Make this game in an applet. You might use the card layout to handle the different screens.
Design the applet and the layouts before you get started. This needs to be handed in, so make sure that it is neatly labeled with widget names.
Make sure that your program has methods: you need to know what letters have been already guessed, print out the word with the letters already guessed (eg. B_N_N_), handle the word guesses, print out a winning message, count the number of tries.
Test your program with 3 well chosen words. Some test cases: try to win a game, try to lose a game, guess a letter that is already guessed. This section needs to be written up in a testing chart.
Enhancements:
In
traditional hangman, one piece of a stick figure is drawn for each wrong guess.
Modify the hangman program to illustrate the traditional 'hangman' near the top
of the window. When six wrong guesses are made, the hangman part of the program
output should look similar to:
---------
|
o
/|\
/ \
You might also have a list of default words. Each game would randomly select a word for the user to guess.
Rubric:
| Knowledge (16) | Level 4 | Level 3 | Level 2 | Level 1 |
| Methods (12) | Enhancements to the program. A hangman, etc. | Letters already guessed, takes guess, displays winner, displays word with --- in it. | Most of level two. Letters already guessed missing. | Major problems with game. |
| Applet (4) | Panels, multiple widgets. Outstanding use of design. Something extra. | Panels, multiple widgets. Very good design. Colour. | Many widgets. Some problems with panels. | Major problems with applet or textbased. |
| Applications (6) | Level 4 | Level 3 | Level 2 | Level 1 |
| Testing (6) | Well formatted. more than 3 words, excellent choices. | 3 words tested. Excellent guesses. Tested every line of the program. | Some testing done. Problems with write up. | Very weak submission or missing. |
| Communication (8) | Level 4 | Level 3 | Level 2 | Level 1 |
| Comments (4) | Pre/Post or @return /@param are extremely well done. Great comments. | Pre/Post or java doc is very well done. Many good comments. | Pre/Post or java doc are present. Some comments. Title comments at least. | Pre/Post or java doc is extremely weak or missing. Very poor comments. |
| Methods (4) | Program is well decomposed. Nice design of methods. | Program has methods. Fairly good design. | Program has some methods. Design is weak. | Design is really weak. |