I got another nooby question to Java gurus
Basically what I want is:
- Take word;
- Transform it to arrayOfChar;
- Hide it to following manner:
_ _ _ _;
I could get to to second step, however when I try to hide word in underscores it shows as ____ rather than _ _ _ _.
Code for it:
//Randomly picks word from Array which played
public String pickWord(){
String guessWord = (wordsList[new Random().nextInt(wordsList.length)]);
return guessWord;
}
//Hides picked word
public char[] setWord(){
word = pickWord().toCharArray();
for (int i = 0; i < Array.getLength (word); i++) {
word[i] = '_';
}
return word;
}
You will need to allow for the spaces in your new char array: