이것은이 사이트의 첫 번째 질문이므로 총 멍청이가 아니려고 노력할 것입니다.특정 문자의 자바 대체
현재 Java에서 행맨 게임을 만들고 있습니다. 우리가 우리에게
의 출력을 제공하는 "_ _ _ _ _" "유령" 유령이 "_"로 대체됩니다 단어,hiddenWord = ghost.length();
for (i=0; i < ghost.lenth(); i ++)
System.out.print("_ ")
을 부여하는 경우 그래서 내 질문은
내가 대체 어떻게 "O", 추측됩니다 우리는 문자 "O" 편지를 추측 말할 수 있습니다`
"_ _ _ _ _" with
"_ _ o _ _ "
내 현재의 클래스 파일
public void pickWord()
{
String[] listOfWords;
listOfWords = new String[10];
listOfWords[0] = "shenanigans";
listOfWords[1] = "conversely";
listOfWords[2] = "octopus";
listOfWords[3] = "dizzy";
listOfWords[4] = "malicious";
listOfWords[5] = "goosebumps";
listOfWords[6] = "flying";
listOfWords[7] = "staff";
listOfWords[8] = "xylophone";
listOfWords[9] = "zapping";
Random generator = new Random();
int lineNumber = generator.nextInt(9);
disguisedWord = listOfWords[lineNumber];
}
public void displayMark()
{
for(int i = 0; i < disguisedWord.length(); i ++)
underscore = underscore + "_ ";
System.out.println(underscore);
}
public void makeGuess() throws IOException
{
System.out.println("Your word is " + disguisedWord.length() + " letters long.");
System.out.println("Feel free to guess a letter.");
guess = (char)System.in.read();
제 displayMark 메서드를 그 것으로 대체해야합니까? –
당신은 내 구주 –