我不是焊工
import java.util.Scanner;
public class Jsb {
public static void main(String[] args) {
while (true) {
result(input(), random());
System.out.println("+++++++++++++++");
}
}
public static int input() {
System.out.println("请输入:1-剪刀,2-石头,3-布");
Scanner sc = new Scanner(System.in);
String s = sc.next();
int x = 0;
if (s.equals("1")) {
x = 1;
System.out.print("我:剪刀!");
} else if (s.equals("2")) {
x = 2;
System.out.print("我:石頭!");
} else if (s.equals("3")) {
x = 3;
System.out.print("我:布!");
} else {
System.out.print("输入有问题,我再思考一下……");
System.exit(0);
}
return x;
}
public static int random() {
int h = (int) (Math.random() * 3 + 1);
System.out.println(h);
switch (h) {
case 1: System.out.println("PC:……………… 剪刀!");
break;
case 2: System.out.println("PC:……………… 石头!");
break;
case 3: System.out.println("PC:……………… 布!");
break;
default: System.out.println("PC:……………… 不和你玩了!");
break;
}
return h;
}
public static void result(int n, int m) {
if (n == m) {
System.out.println("平局。");
} else {
if (n == 1) {
if (m == 2) {
System.out.println("你输了");
} else if (m == 3) {
System.out.println("你赢了");
}
} else if (n == 2) {
if (m == 1) {
System.out.println("你赢了");
} else if (m == 3) {
System.out.println("你输了");
}
} else if (n == 3) {
if (m == 1) {
System.out.println("你输了");
} else if (m == 2) {
System.out.println("你赢了");
}
}
}
}
}