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

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.

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

Step by Step Solution

3.34 Rating (163 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a import javaxswing import javaawt import javaawtevent public class JSecretPhrase extends JPanel implements ActionListener final int NUM 26 JLabel greeting new JLabelSecret Phrase Game JLabel promptLa... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Programming 8th Questions!