public class hangPhrase { /* This program monitors a game of hangPhrase, which is sort of a merger of the games Hangman and Wheel of Fortune. A player enters a word or phrase and the second tries to guess it, one letter at a time. The program keeps track of the guesses and displays the letters in the phrase that have been located so far. The game is over when the second player guesses the phrase or makes 6 incorrect guesses. After each guess, the method "showGallows" inside the Gallows class is called to display a partially-hanged player, according to the number of wrong guesses that have been made so far: 1 = the head, 2 = the head and torso, 3 and 4 add an arm, and 5 and 6 add a leg. showGallows also displays in that window the partially-guessed phrase and the letters that the player has used so far. */ // Obtain a secret phrase from the user and wipe it off the screen static String getSecretPhrase () { System.out.println("Enter a secret phrase to be guessed: "); String secretPhrase = Keyboard.readString(); for (int i=0; i<30; i++) // clear the text window System.out.println(); return secretPhrase; } // Prompt the user to enter the next letter, checking that it // hasn't already been guessed static char getNextGuess (String lettersUsed) { System.out.println("Enter the next letter: "); String nextLetter = Keyboard.readString(); while (lettersUsed.indexOf(nextLetter.charAt(0)) >= 0 || nextLetter.length()!=1) { System.out.println("Letter already guessed or invalid; try again: "); nextLetter = Keyboard.readString(); } return nextLetter.charAt(0); } static String updatePhrase(String pp, String sp, char nl) { // Return the String that results from replacing each character pp[i] // by nl for which nl == sp[i], for 0 <= i < sp.length(). That is, // all occurrences of '-' in pp that correspond to occurrences of nl // in sp are replaced by nl. for (int i=0; i