100%(1)1 out of 1 people found this document helpful
This preview shows page 2 - 4 out of 6 pages.
Devise suitable test data (in addition to the above example) to test your program. The test data together with test results should be submitted as part of your external documentation. Question 2. Hangman is a game that can be played between two players. One player thinks of a word and the other tries to guess it by suggesting letters. The word to guess is represented by a row of dashes, giving the number of letters in the word. If the guessing player suggests a letter which occurs in the word, the other player writes it in all its correct positions. See (game) for further details). Design, write in Java, test and document a program which will allow a user to play a simplified version of the hangman game. The program will display the secret word in its disguised form (a row of question marks (?), and invite the user to enter an alphabetic letter. If the letter occurs in the secret word, the program will display it in all its correct positions and ask the user to enter another letter as a guess. The process continues until the user guesses the word correctly! The program will also display a running total of the number of guesses made and the number of wrong guesses. Design two classes for this program - a class that could be used to play a simplified version of the hangman game (as described in the above paragraph) and a client class that uses the hangman class. Provide the UML class diagram for the hangman class. The hangman classwill have at least the following attributes: •The secret word or phrase (a String, which may include embedded white spaces and punctuation characters) •The disguised word, in which each unknown alphabetic letter in the secret word is replaced with a question mark (?). When an unknown letter is guessed correctly, it will replace the corresponding question mark(s) in the disguised word. For example, if the secret word is abracadabra and the letters aand b have been guessed, the disguised word would be ab?a?a?ab?a. •The number of guesses made. •The number of incorrect guesses. The hangman classwill have at least the following methods (write the preconditions and postconditions of each method) : •makeGuess(ch) guesses that character ch is in the word. •getDisguisedWord returns a String containing correctly guessed letters in their correct positions and unknown letters replaced with ?•getSecretWord returns the secret word. •getGuessCount returns the number of guesses made. •isFound returns true if the hidden word has been discovered. Devise any additional methods and attributes that are needed in the class and are not listed above. Note that when treating letters of the alphabet, case is not important (i.e., the uppercase and lowercase forms of the same letter are to be treated the same). Write a client classthat tests the hangman class. The client class should allow the user to play three .