import java.util.*;
public class GuessGame {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int win = 0, lose = 0, draw = 0;
while (true) {
System.out.println("Please enter your choice (0 for rock, 1 for paper, 2 for scissors):");
int player = input.nextInt();
if (player < 0 || player > 2) {
System.out.println("Invalid input, please try again.");
continue;
}
int computer = new Random().nextInt(3);
System.out.print("The computer chooses ");
switch (computer) {
case 0:
System.out.println("rock.");
break;
case 1:
System.out.println("paper.");
break;
case 2:
System.out.println("scissors.");
break;
}
if (player == computer) {
System.out.println("It's a draw.");
draw++;
} else if ((player == 0 && computer == 2) || (player == 1 && computer == 0) || (player == 2 && computer == 1)) {
System.out.println("You win!");
win++;
} else {
System.out.println("You lose.");
lose++;
}
System.out.println("Wins: " + win + ", Losses: " + lose + ", Draws: " + draw);
System.out.println("Do you want to play again? (y/n)");
String answer = input.next();
if (!answer.equalsIgnoreCase("y")) {
break;
}
}
}
}