• 人机猜拳


    import java.security.acl.Permission;
    
    public class startGuess {
            Permission jia;
            Comparator yi;
            int count;
         
            public void initial() {
                jia = new Person();
                yi = new Computer();
                count = 0;
            }
         
            public void showout12() {
                initial();
                System.out.println("----------欢迎进入游戏世界-----------");
                System.out.println("**********************************");
                System.out.println("***   猜拳,开始         ***");
                System.out.println("**********************************");
                System.out.println("出拳规则:1.剪刀  2.石头  3.布");
                System.out.println("请选择对方角色(1:刘备   2:孙权  3:曹操):");
                Scanner input = new Scanner(System.in);
                int h = input.nextInt();
                switch (h) {
                case 1:
                    yi.name = "刘备";
                    break;
                case 2:
                    yi.name = "孙权";
                    break;
                case 3:
                    yi.name = "曹操";
                    break;
                }
                System.out.println("请输入你的名字:");
                jia.name = input.next();
                System.out.println("你选择了" + yi.name + "对战");
                System.out.println("要开始吗?y:是  n:否");
                String con = input.next();
                while (con.equals("y")) {
                    int per;
                    int com;
                    if (con.equals("y")) {
                        per = jia.showout();
                        com = yi.showout11();
                        if ((per == 1 && com == 1) || (per == 2 && com == 2)
                                || (per == 3 && com == 3)) {
                            System.out.println("结果:和局,真衰!");
                        } else if ((per == 1 && com == 3) || (per == 2 && com == 1)
                                || (per == 3 && com == 2)) {
                            System.out.println("结果:恭喜,你赢了!");
                            jia.Score++;
                        } else {
                            System.out.println("结果说:^_^,你输了,真笨!");
                            yi.Score++;
                        }
                        count++;
                    }
         
                    System.out.println("是否进行下一轮.y:是   n:否");
                    con = input.next();
                }
                showgg();
            }
         
            public void showgg() {
                System.out.println("-----------------------------");
                System.out.println(jia.name + " VS " + yi.name);
                System.out.println("对战次数:" + count);
                System.out.println("姓名" + "	" + "积分");
                System.out.println(jia.name + "	" + jia.Score);
                System.out.println(yi.name + "	" + yi.Score);
         
                if (jia.Score > yi.Score) {
                    System.out.println("甲赢了");
         
                } else if (jia.Score < yi.Score) {
                    System.out.println("乙赢了");
         
                    System.out.println("-----------------------------");
                }
            }
    
    
        }
  • 相关阅读:
    微信小程序开发9-宿主环境(2)
    微信小程序开发8-小程序的宿主环境(1)
    微信小程序开发7-JavaScript脚本
    微信小程序开发6-WXSS
    点击底部input输入框,弹出的软键盘挡住input(苹果手机使用第三方输入法 )
    极光推送能获取 registrationId,但是接收不到通知
    App 运行后屏幕顶部和底部各留黑边问题
    App 分辨率相关
    配置隐私协议
    极光推送小结
  • 原文地址:https://www.cnblogs.com/cw172/p/9789059.html
Copyright © 2020-2023  润新知