這裏是我到目前爲止的代碼(當然,while循環):while循環,儘管條件不是循環得到滿足
public class Lab10d
{
public static void main(String args[])
{
Scanner keyboard = new Scanner(System.in);
char response = 0;
//add in a do while loop after you get the basics up and running
String player = "";
out.print("Rock-Paper-Scissors - pick your weapon [R,P,S] :: ");
//read in the player value
player = keyboard.next();
RockPaperScissors game = new RockPaperScissors(player);
game.setPlayers(player);
out.println(game);
while(response == ('y'))
{
out.print("Rock-Paper-Scissors - pick your weapon [R,P,S] :: ");
player = keyboard.next();
game.setPlayers(player);
//game.determineWinner();
out.println(game);
out.println();
//
}
out.println("would you like to play again? (y/n):: ");
String resp = keyboard.next();
response = resp.charAt(0);
}
}
它應該運行代碼的其他次,直到正被輸入
當我輸入唉,它應該重新運行的代碼,但不會
......和你的問題是什麼? – apnorton
您的括號已關閉 – epascarello
並且您有不匹配的括號?我們可以看到完整的代碼嗎? – u8sand