Homework 8

Skills: Interfaces, Abstract Classes, Polymorphism, Class Design, GUIs, Event Handling

Classes: Color, Random, String, ArrayList, Components, Events

Due Week 12: Saturday by 10pm.

In this program you will write a GUI program to play the game Hangman.

Design

Algorithm, Action Plan, and Implementation

Deliverables

  1. HangmanAlgorithm.pdf
  2. HangmanActionPlan.pdf

  3. PlayGame.java (main program, based on the HelloWorldSwing.java example from Oracle.)

  4. HangmanGUI.java (Hangman GUI and code to play the game)

    It should implement the StringHandler (code is below):

    public class HangmanGUI extends LayoutGUI implements StringHandler

  5. JSecretString.java (copy SecretString from HW4)
  6. PhraseList.java (from HW4) - have your main() take the file name for the phrases as a command-line argument.

  7. SingleUseButton.java - Class for the letter-buttons (A-Z). Note: this code is provided for you; use it for the buttoms I have instructed you to - no more and no less!
  8. StringHandler.java - Interface to use with the SingleUseButton class. This insterface defines a class that processes a string received form clicking on a SingleUseButton. Note: this code is provided for you; use it!
  9. HangedMan.java - Class that graphically represents the hanged man. Note: this code is provided for you; use it!
  10. Are there any more classes??

Hangman Game Design During Lecture:

Note that this is a suggestion to give you an idea of the components. You may change the way components are layed out on the screen if you wish. For instance, it is fine to put the hanged-man on the right side or middle of the screen if you prefer. A pop-up showing the result of the game is optional, but you msut find a way to indicate that the game is over (and if they won or lost).

Also, selecting the internal layout is up to you, as long as you use each one (Flow, Grid, and Border) and try to get a reasonable placement of your components.

I have given you a LetterButton class to use - use it in the the Grid layout for your graphical "keyboard". Figure out how to get the letters in the Grid layout and how to label each one with the letter of the alphabet it represents.

Below is a picture of ideas to get you started on your GUI layout-design. Do include a label that shows your name and Andrew ID and make sure it is visible on the screen.