到目前为止,这是我的代码(好吧,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);
}
}
它应该额外运行代码,直到输入 n
当我输入ay时,它应该重新运行代码但没有