MeltFrosty - demo by Halloween (no credit for late programs!!)

Write a Java program that plays what is sometimes called "hangman", but what we will call "MeltFrosty". Here's how it goes: Make sure you understand how the entire game works before you begin writing code!

Rules and an Example:

  1. The program selects a secret word. For this example, suppose the secret word is "WILLAMETTE".
  2. The program replaces each letter in the secret word with an '*' and displays the result: **********
  3. On each turn, the user guesses a single letter.
  4. If the letter is in the word, the program replaces each '*' for that letter with the letter itself. For example, if the user guesses 'E', then the secret word display changes to ******E**E. The next time, if they guess 'L', the display changes to **LL**E**E.
  5. If the letter is not in the word, then the program says "Sorry frosty!" and frosty melts. (Use a Frosty7 class here -- a Frosty7 object is guaranteed to melt in 7 steps.)
  6. In any case, right or wrong, add the letter to the Letters Tried collection. For example, if the user has guessed 'E', 'S', 'L', and 'X', then the Letters Tried area would display ELSX
  7. After 7 guesses, the game is over. If Frosty is all melted, the player loses and the program reveals the secret word. On the other hand, if the secret word has been discovered, the player is the winner and the hero for saving Frosty!

Part I: Design and Basic Functionality

Design the interface for the game. Draw a sketch of your GUI: show what Buttons, Labels, and TextFields you will need and what their functionality is to be. Also decide where you will place the Snowperson7. However, remember to program incrementally and test your design as you go. For example, to start with, you should:

Part II: The Completed Game

Complete the project by adding the bells and whistles left out of part I. In particular,

Hint: Transforming **LL**E**E into **LL*ME**E on the guess of an 'M'.

Suppose: 1) the secret word is "WILLAMETTE"; 2) the display word is currently "**LL**E**E"; and, 3) the guessed letter is 'M'. Here is how you can produce the new form of the display word:
For each letter in the secret word,
    If it is not the guessed letter
        move the corresponding character in the old display word to the new display word.
    else //it is the guessed letter, so
        move that letter to the new display word.

The first four characters, "**LL*", get moved, one letter at a time, from the old display word to the new display word. Then, 'M' gets added to the new display word to give us "**LL*M". Finally, "E**E" gets moved, one letter at a time, from the old display word to the new display word, yielding: "**LL*ME**E"

Extra credit

  1. Alphabetize the letters in the Letters Tried display.
  2. Instead of making the user type letter, put up all the letters and let them click them; disappear letters that have already been guessed
  3. Read the words from a file and choose one at random