Hangman Game in Java

droppedImage-13

Code Diagram 2

Hangman Flowchart2 copy

Functional Requirements

  • Words
    The game has to randomly choose a word from a list of 20 words stored in an array of a word.
    The following words should be part of 20 word list: litter, beanbag, opening, settlement, monkey, turtle, bigbang, comic, statement, iteration, null, integer, float, iPhone, smartphone, version, control, a, i, the
  • Display
    Display the game as per the example screens.
  • Lives
    There is no need to show a hang man. Instead each time a letter is picked reshow the lives left.
  • Number of characters
    Display the number of characters in the word.
  • Input letter
    Ask the user to input a letter. They cannot input the same letter twice. If the letter is not part of the word they loose a life. If it is correct show the letter in its position in the word. Keep asking for letters until the user runs out of lives. At the end of the game ask if they want to play again
  • Javabook Classes
    Program  must use the javabook classes for data entry and displaying the hangman screens.
  • Pictures
    A text based version of hangman, using the javabook classes is what is required NOT a picture version

Stage 1 Components

  • List of 20 words, array constructed
  • Random pick of a word
  • Enter letter with error checking
  • Enter zero with error checking and exit

Stage 2 Components

  • Check if letter used before, if yes ask to re-enter
  • Check for multiple character matches
  • Keep match position for word update
  • if no match – deduct a life, show screen
  • if no match and if lives == 0, show screen
  • if match – show screen, re-enter at ask for another character
  • if match and word guessed, show screen
  • Process to place guessed words into blank word to guess
  • Check used letters and characters in word loops correct

Stage 3 Components

  • Play again screen from won, with error checking
  • Play again screen from lost, with error checking
  • Play again picks word from list of 20 does not rebuild list

Game Logic

Screen Shot 2013-12-06 at 17.56.02

 

 

Hangman Flowchart2 copy 2

App Class:

 

Game Class:

 

Letter Class:

 

Word Class:

 

Word List Class:

 

 

 

Tagged: