Question: Implement a java class named Hangman could be used to play a game of hangman. The class has the following attributes: The secret word The
Implement a java class named Hangman could be used to play a game of hangman. The class has the following attributes:
The secret word The disguised word, in which each unknown letter in the secret word is replaced with a question mark (?). For example, if the secret word is "constructor" and the letters c, n, o and r have been guessed, the disguised word would be "con??r?c?or" The number of guesses made The number of incorrect guesses made
The Hangman class will have methods to:
Create a new game of Hangman (given a secret word only) [constructor] [No copy constructor needed]
*** Add only accessors for: getSecretWord getDisguisedWord getNumberOfGuesses getIncorrectGuesses makeGuess(char c) - guesses that character c is in the word. If so, increment number of guesses, change the disguised word to replace question marks ? with the correct character. If incorrect, increment both incorrect guesses and number of guesses. isFound() - returns true if the secret word is discovered (e.g. there are no more question marks left in the disguised word)
[No toString() or equals() methods are needed]
Also, implement a demo class to play a game of Hangman!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
