import java.util.Scanner;
import java.util.Random;
public class Main {
public static void main(String[] args) {
System.out.println("程序已启动");
System.out.println("剪刀\t石头\t布");
int a = 0;
for (int i = 1; i <= 5; i++) {
System.out.println("第" + i + "局");
Scanner scanner1 = new Scanner(System.in);
String s = scanner1.nextLine();
int randomNumber = new Random().nextInt(3);
//1 代表石头 2 代表剪刀 3 代表布
switch (randomNumber + 1) {
case (1)://石头
{
System.out.println("电脑本次出的是石头");
if ("石头".equals(s)) {
System.out.println("打平了");
} else if ("剪刀".equals(s)) {
System.out.println("赢了");
a++;
} else if ("布".equals(s)) {
System.out.println("输了");
a--;
}
break;
}
case (2)://剪刀
{
System.out.println("电脑本次出的是剪刀");
if ("石头".equals(s)) {
System.out.println("输了");
a--;
} else if ("剪刀".equals(s)) {
System.out.println("打平了");
} else if ("布".equals(s)) {
System.out.println("赢了");
a++;
}
break;
}
case (3)://布
{
System.out.println("电脑本次出的是布");
if ("石头".equals(s)) {
System.out.println("赢了");
a++;
} else if ("剪刀".equals(s)) {
System.out.println("输了");
a--;
} else if ("布".equals(s)) {
System.out.println("打平了");
}
break;
}
}
}
if (a > 0)
System.out.println("本次游戏胜利");
else if (a == 0)
System.out.println("本次游戏平局");
else System.out.println("本次游戏失败");
// write your code here
}
}