人机猜拳java

public class wang {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Person o = new Person();
Computer on = new Computer();
int count = 0;
Person person;
Computer computer;
int sc;
int num = 0;
int x;
int sum = 0;
String name = "";
System.out.println("----------------欢迎进入游戏世界---------------------");
System.out.println("\n");
System.out.println("\t\t*******************\t\t");
System.out.println("\t\t****\t猜拳,开始\t***\t\t");
System.out.println("\t\t*******************\t\t");
System.out.println("出拳规则:1.剪刀2.石头3.布");
System.out.println("请选择对方角色(1:刘备2:孙权3:曹操)");
x = input.nextInt();
String name1 = "";
switch (x) {
case 1:
name1 = "刘备";
System.out.println("你选择了刘备对战");
break;
case 2:
name1 = "孙权";
System.out.println("你选择了孙权对战");
break;
case 3:
name1 = "曹操";
System.out.println("你选择了曹操对战");
break;
}
System.out.println("请输入你的姓名:");
String n = input.next();
System.out.println(n + "VS" + name1);
String con = "";

System.out.println("\n要开始码?(y/n)");
con = input.next();

while (con.equals("y")) {
    int perFist;
    int compFist;
    perFist = o.showFist();
    compFist = on.showFist();
    if ((perFist == 1 && compFist == 1)
            || (perFist == 2 && compFist == 2)
            || (perFist == 3 && compFist == 3)) {
        System.out.println("结果:和局,真衰!\n");

    } else if ((perFist == 1 && compFist == 3)
            || (perFist == 2 && compFist == 1)
            || (perFist == 3 && compFist == 2)) {
        System.out.println("结果:恭喜,你赢了!");
        num++;
    } else {
        System.out.println("结果说:^_^,你输了,真笨!\n");

        sum++;
    }
    count++;
    System.out.println("\n是否开始下一轮(y/n):");
    con = input.next();
}
System.out.println("------------------------------------------");
System.out.println(n + "VS" + name1);
System.out.println("对战次数:" + count);
System.out.println("姓名\t\t得分");
System.out.println(n + "\t\t" + num);
System.out.println(name1 + "\t\t" + sum);
if (sum < num) {
    System.out.println("结果:恭喜");
} else if (sum == num) {
    System.out.println("结果:还好,平局");
} else if (sum > num) {
    System.out.println("结果:呵呵,笨笨,下次加油!");
}
System.out.println("------------------------------------------");

}
}

你可能感兴趣的:(人机猜拳java)