-1
我想寫一個Hang子手遊戲項目,其中用戶可以有15個猜測和4個空間來檢查。數字(空格)由空格分隔。這是我的代碼,但由於某些原因它不起作用。任何幫助表示讚賞!如何讀取白色空間之間的整數?
System.out.println("\nPlease enter the letter you want to guess: ");
char guessLetter = input.next().charAt(0);
if (Character.isLetter(guessLetter)){
System.out.println("Please enter the spaces you want to check (separated by spaces): ");
String guessSpaces = input.next();
for (int index = 0; guessSpaces.charAt(index) == ' ';index++){
if(guessSpaces.charAt(index)== secretWord.indexOf(guessLetter)){
System.out.println("You guess is in the word");
看起來你沒有正確複製程序(沒有右花括號)。 – Michael
是啊!我只複製了我有疑問的部分。我不想讓任何人認爲我需要整個代碼的幫助lol – minnie
你的for循環對我來說沒有任何意義。你能解釋一下你認爲for循環正在做什麼嗎? – pczeus