I have tried all night to find an answer and haven't managed to get anything. What i am trying to do is to generate 2 words, a secretWord and a hiddenWord. The hidden word is the same length as the secretWord but with all the characters replaced with a symbol. I have seen how to do this with setBuilder or arrays, but im not at the point where i am comfortable using them, and would like to know if it is possible without them.
Im sorry if this seems rambling, but no where i have looked has a sollution that doesnt include either arrays or setbuilder
public class Hangman {
public static void main( String[] args ) {
Hangman game = new Hangman();
game.initialize("Happiness");
System.out.println( "Lets play a round of hangman");
game.playGame();
Scanner keyboard = new Scanner(System.in);
char guess = 'a';
int secretLength;
public class playGame {{
while (isFound == false)
System.out.println("The disguised word is " + game.getDisguisedWord);
System.out.println("Guess a letter: ");
game.makeGuess();
}}
private class isFound {{
if (getSecretword.secretWord.equals(getDisguisedWord.disguisedWord)){
}
}}
public class getDisguisedWord {{
return disguisedWord;
}}
public class getSecretWord {
initialize.getsecretWord();
}
private class makeGuess {{
char guess = keyboard.next().charAt( 0 );
for (int index = 0; index < secretWord.length(); index++)
if (initialize.secretWord.charAt(index) == guess)
hiddenWord.setCharAt(index, guess);
}}
public class initialize {{
this.secretWord();
int secretLength = secretWord.length();
while (secretLength > 0){
hiddenWord += '?';
}
}
}