NOT replacing ? with letter guessed
Posted
by
user3720541
on Stack Overflow
See other posts from Stack Overflow
or by user3720541
Published on 2014-06-08T21:16:27Z
Indexed on
2014/06/08
21:24 UTC
Read the original article
Hit count: 157
java
i need my code to replace the ? with the letter guessed. The ? needs to be replaced with a for only those to spots. The word in array is parameter.
public static void replace(String[] wordOne, String blanks, char guess)
{
int i;
blanks = wordOne[0];
for (i = 0; i < wordOne.length; i++)
{
for (int j = 0; j < wordOne[0].length(); j++)
{
blanks = blanks.replace(blanks.charAt(j), '?');
if (wordOne[0].charAt(i) == guess)
{
blanks = blanks.replace(blanks.charAt(i), guess);
}
}
}
System.out.println(blanks);
}
}
© Stack Overflow or respective owner