Hangman
Please can somebody help me with the hangman code here.
I wish to update the strClue after the first guess such that it icludes the letter guessed. This is just the section that I need help. The rest of the classes have been worked out.
The code was done using Netbeans
public class HangMan {
char target;
StringBuffer answer = new StringBuffer();
String strTarget;
StringBuffer strDisplay;
StringBuffer strClue;
/** Creates a new instance of HangMan */
public HangMan(){
// Initialise the target string
// Initialise the display string
// maybe print them out
char target;
strTarget = "HANGMAN";
strDisplay = new StringBuffer();
int len = strTarget.length();
for(int i = 1; i <= len; i++)
strDisplay.append("_ ");
System.out.println(strDisplay.toString());
}
public void checkGuess(char strGuess){
// compares guess with target and prints out the next clue
char target;
target = strTarget.charAt(0);
int len = strTarget.length();
for(int i = 0; i < len; i++){
strClue = new StringBuffer();
strClue.append(strDisplay.toString());
if(strGuess == strTarget.charAt(i)){
System.out.println("Found "+ strGuess);
answer.append(strGuess);
strClue.append(answer.toString());
}
else
answer.append('_');
}
System.out.println(answer.toString());
System.out.println(strClue.toString());
}
public static void main(String[] args) {
HangMan hangman = new HangMan();
hangman.checkGuess('N');
}
}

