a. In Chapters 7 and 8, you created a game named Secret Phrase in which the user

Question:

a. In Chapters 7 and 8, you created a game named Secret Phrase in which the user guesses a randomly selected secret phrase by entering one letter at a time. Now create a GUI application that plays the game, allowing users to choose a letter by selecting one of 26 buttons.

Disable a letter button once it has been guessed, and after the puzzle is complete, disable all the letters. Figure 16-45 shows a typical execution after the user has guessed an E, which is in the phrase. Save the file as JSecretPhrase.java.

Secret Phrase Game Play our game - guess the phrase Enter one letter **** ***E **** ** Correct! Enter one letter A B D G H J K. M R V Figure 16-45 Typical execution of the JSecretPhrase program

b. Make the JSecretPhrase game more like the traditional letter-guessing game Hangman by drawing a “hanged” person piece by piece with each missed letter. For example, when the user chooses a correct letter, place it in the appropriate position or positions in the phrase, but the first time the user chooses a letter that is not in the target phrase, draw a head for the “hanged” man. The second time the user makes an incorrect guess, add a torso. Continue with arms and legs. If the complete body is drawn before the user has guessed all the letters in the phrase, display a message indicating that the player has lost the game. If the user completes the phrase before all the body parts are drawn, display a message that the player has won. Save the game as JSecretPhrase2.java.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: