代码如下
package HomeWork_1;
import java.util.Scanner;
public class PlayGame {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int winTime1 = 0, winTime2 = 0;
while (winTime1 < 2 && winTime2 < 2) {
System.out.print("scissor(0), rock(1), paper(2) :");
int computer = (int) (Math.random() * 3);
int user = in.nextInt();
switch (computer) {
case 0:
System.out.print("The computer is scissor.");
break;
case 1:
System.out.print("The computer is rock.");
break;
case 2:
System.out.print("The computer is paper.");
break;
}
System.out.print((user == 0) ? "You are scissor."
: (user == 1) ? "You are rock."
: (user == 2) ? "You are paper."
: "\nInput error, please re-enter.");
if (user == computer) {
System.ou