I need an algorithm, class, and main method class for the following please: Cons
ID: 3938548 • Letter: I
Question
I need an algorithm, class, and main method class for the following please:
Consider a class that 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 abracadabra, and the letters a , and b have been guessed, the disguised word would be ab?a?a?ab?a • The number of guesses made • The number of incorrect guesses It will have the following methods: • MakeGuess(c) guesses that character c 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. Perform the following actions: • Write a method heading for each method. • Write preconditions and postconditions for each method. • Write some Java statements that test the class. • Implement the class. • List any additional methods and attributes needed in the implementation that were not listed in the original design. List any other changes made to the original design. • Write a program that implements the game of handgman, using the class you wrote for part d.
Explanation / Answer
public class main { private int length; private String word; private String result; private String buffer; public main(String aword) { result = ""; word = aword; length = word.length(); buffer = ""; } public String guess(String aguess) { for(int i = 0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.