CS312 Hangman Assignment CS 312 Assignment 6, Hangman Programming Assignment 6: Individual Assignment. You must complete this assignment by yourself. You cannot work with anyone else in the class or with someone outside of the class. You may not copy solutions from the world wide web. You are encouraged to get help from the instructional staff. Placed online: Tuesday, March 1 20 points, ~2% of total grade Due: no later than 11 pm, Thursday, March 10 General Assignment Requirements There is an associated Perusall reading assignment for this program. Check Canvas for details, The purpose of this assignment is to implement a program that plays the game of hangman. To do the program you will practice the following techniques. Practice creating a structured program to solve a problem. Write methods that use parameters. Write an interactive program. Practice using indefinite loops, aka while loops. Use methods from the String class and another instructor provided class. For this assignment you are limited to the language features in chapters 1 through 5 of the textbook. Provided Files: Hangman.java (A shell file with a main method and the header information.) PhraseBank.java (Another program that is used to read from a file and provide phrases for the game.) HangmanMovies.txt (A file with movies to use for the game.) ProSportsTeams.txt (Another file that can be used to play the game. You don't need this file to actually complete the program.) Description: Write a program to play Hangman. The program picks a secret phrase from a list of phrases or words.. The human player guesses letters until they reveal the entire phrase or lose due to picking too many letters that are not in the phrase. There are three sample files: hangmanOutput1.txt, hangmanOutput2.txt , hangmanOutput3.txt (shortest sample, demonstrates a loss), and hangmanOutput4.txt (various bad inputs). Use a diff tool such as the one at this website (www.diffchecker.com/) to ensure your program produces the correct output. Even minor differences in output will cause you to fail grading tests and lose points. Note, the PhraseBank always picks topics in the same order. This is necessary for consistency when testing. See below for changes to your PhraseBank if you want it to pick phrases at random. Your program must: display an intro (This is already done.) Create a new PhraseBank object. (This is already done in the main method of the Hangman.java shell file.) . The PhraseBankk data type has two methods for you to use, getTopic() which returns a String that is the topic for the phrases in the file and getNextPhrase() which returns a String that is the next secret phrase for the game. Each secret phrase contains only upper case letters and underscore characters in place of spaces. The program then plays rounds of Hangman until the user wants to stop. Use a while loop for this. At the start of each round the program gets a secret phrase from the PhraseBank object. Use another while loop to play each round of Hangman. Each round, the program displays the current form of the secret phrase. Spaces are shown as underscore characters. Letters that have not been guessed are shown as asterisks. Letters that have been guessed are shown. The program then displays the letters that have not been guessed so far in alphabetical order. Next the program prompts the user for the next guess, a single letter. If the value entered is not a letter or it is a letter that has already been guessed the program prompts the user again until they enter a letter that has not been guessed yet. It is possible the user enters more than a single character or a character that has already been guessed. You can assume the user will always enter at least one non whitespace character. If they enter more than a single character choose the first character entered. If the first character is a lower case letter, convert it to upper case. Use yet another while loop to ensure the user input is valid. The results of the guess are shown. If the guessed letter appears in the secret phrase all instances of that letter are revealed. If the guessed letter does not appear the number of wrong guesses is incremented. If all of the letters in the secret phrase are revealed the player wins. If the player makes 5 wrong guesses they lose. (It should be VERY easy to change the number of wrong guesses allowed.) After the first game is completed the program will ask the user if they want to play again. As long as the user responds they want another game the program continues. Approach: Divide the program into parts. Complete and test each part before moving on. Use the methods from the String class to help make your job easier. The String methods used in the sample solution are the length, charAt, contains, indexOf, substring, and toUpperCase methods. Use a String variable to store the letters that have not been guessed, but DO NOT store the hyphens that appear between letters when displayed as a part of this String. Print the hyphens out, but do not store them in the String with the letters that have not been used yet. Failure to follow this requirement shall result in a -2 when the assignment is graded. The reason for this requirement is to separate concerns, computation and display in this case. Divide the program up into methods to provide a structured solution. Some of the methods will be void and others will return values. You will have to make use of parameters, for loops, while loops, and if statements. By way of comparison my solution has 15 methods including the main method. No method is more than 17 total lines including the method header and the closing brace. The program is about 200 lines long including single braces and blank lines, but not including the large comment at the top. When finished turn in your Hangman.java program via Canvas under assignment 6. Checklist: Did you remember to: review the general assignment requirements? worked on the assignment by yourself? fill in the header in your file Hangman.java? complete the Hangman.java so it plays the game correctly? ensure your program does not suffer a compile error or runtime error? follow the class style guide? ensure your output matches the given output exactly using a diff tool? use only Java constructions from chapters 1- 5 of the book? used two hyphens between letters not guessed? turn in your Java source code in your Hangman.java program via Canvas before 11 pm, Thursday, March 10? You can create your own data files for the program. The format of these files is: topic on the first line, then the phrases or words one per line. The PhraseBank always picks topics in the same order. This is necessary for consistency when testing. You can alter the creation of the PhraseBank so it has less predictable behavior. Change the call to the constructor for the PhraseBank to send in the boolean value true to randomize it. Note, in the final version of the program you must use the non random version of PhraseBank or you will fail all the tests, Back to the CS 312 homepage.