zoukankan      html  css  js  c++  java
  • JAVA分包下项目部分代码存储

    一、注册时姓名去重和符合汉字格式:

    // 新用户申请加入
        public void NewHuman() {
            System.out.println("========新会员申请加入页面========");
            Scanner sc = new Scanner(System.in);
            String Pname = "";
            while (true) {
                System.out.println("请输入您的游戏名字:");
                Pname = sc.next();
                // 验证是否重名
                int count = newHumanController.selectPname(Pname);
                // 验证是否符合汉字格式
                String reg = "^[u4e00-u9fa5]{0,}$";
                boolean flag = Pname.matches(reg);
                if (count == 0 && flag) {
                    System.out.println("您的游戏名字可用!!");
                    break;
                } else {
                    System.out.println("抱歉,您的游戏名字不正确或已被注册,请重新输入汉字!!");
                }
            }
            System.out.println("请输入您的职业:");
            String Pprofession = sc.next();
            // 调用NewHumanController层的申请加入公会join的方法
            int count1 = newHumanController.join(Pname, Pprofession);
            if (count1 > 0) {
                System.out.println("您已申请完成,已通知相关人员,请您稍等!");
            } else {
                System.out.println("抱歉!您的输入有误!请重新输入:");
            }
        }

    二、修改密码:

    // 改密码
        public void updatepwd() {
            System.out.println("请您输入您的游戏名字:");
            Scanner sc = new Scanner(System.in);
            String Pname = sc.next();
            System.out.println("请您输入要修改后的密码:");
            String pwd1 = sc.next();
            System.out.println("请您再次输入您要修改后的密码:");
            String pwd2 = sc.next();
            while (!pwd1.equals(pwd2)) {
                System.out.println("对不起,两次输入的密码不一致,请重新输入");
                System.out.println("请重新输入您的密码");
                pwd1 = sc.next();
                System.out.println("请再次确认您的密码");
                pwd2 = sc.next();
            }
            int row = newHumanController.updatePwd(pwd2, Pname);
            if (row > 0) {
                System.out.println("修改成功!");
            } else {
                System.out.println("修改失败!");
            }
        }

    三、分等级继而进入各自界面

    // 公会成员登录
        public void login() {
            System.out.println("========公会成员登录页面========");
            System.out.println("请输入您的游戏名称:");
            Scanner sc = new Scanner(System.in);
            String Pname = sc.next();
            System.out.println("请输入您的密码:");
            String Pwd = sc.next();
            // 调用UserController的login方法进行登录
            int count = userController.login(Pname, Pwd);
            if (count > 0) {
                System.out.println("登录成功!");
                // 针对会员的名称搜索其等级进行判断并继而进入下个界面
                int pcount = userController.plogin(Pname);
                if (pcount == 1) {
                    // 会长级别
                    masterView.show1();
                } else if (pcount == 2) {
                    // 团长级别
                    leaderView.show2();
                } else if (pcount == 3) {
                    // 职业导师级别
                    mentorView.show3();
                } else if (pcount == 4) {
                    // DKP管理者级别
                    dkperView.show4();
                } else if (pcount == 5) {
                    // 正式团员级别
                    regularView.show5();
                } else if (pcount == 6) {
                    // 替补队员级别
                    alternateView.show6();
                } else if (pcount == 7) {
                    // 新会员级别
                    memberView.show7();
                }
            } else {
                System.out.println("用户名或密码错误,请重新登录!");
            }
        }

    四、将表1查询结果添加到表2

    // 将状态为1的申请表中的装备的名称、获取人的ID及花费的积分添加到装备分配表
        // 1.查询
        public ArrayList<ApplyforClo> applyforClo() throws SQLException {
            // 获取连接对象
            Connection conn = JDBCUtils.getConn();
            // 获取语句执行平台
            String sql = "select Cclothes,Pid,Cscore from ApplyforClo where Astate=1 ";
            PreparedStatement pst = conn.prepareStatement(sql);
            // 执行sql
            ResultSet rs = pst.executeQuery();
            // 处理结果集
            ArrayList<ApplyforClo> arr = new ArrayList<ApplyforClo>();
            while (rs.next()) {
                ApplyforClo applyforClo = new ApplyforClo();
                applyforClo.setCclothes(rs.getString("Cclothes"));
                applyforClo.setPid(rs.getInt("pid"));
                applyforClo.setCscore(rs.getInt("cscore"));
                arr.add(applyforClo);
            }
            // 释放资源
            JDBCUtils.close(conn, pst, rs);
            return arr;
        }
    
        // 2.增加
        public int addClothes(String Cclothes, int Pid, int Cscore) throws SQLException {
            // 获取连接对象
            Connection conn = JDBCUtils.getConn();
            // 获取语句执行平台
            String sql = "insert into Clothes (Cclothes,Pid,Cscore) values (?,?,?)";
            PreparedStatement pst = conn.prepareStatement(sql);
            // 执行sql
            pst.setString(1, Cclothes);
            pst.setInt(2, Pid);
            pst.setInt(3, Cscore);
            int rs = pst.executeUpdate();
            // 释放资源
            JDBCUtils.close(conn, pst);
            return rs;
        }
    // 将申请表中的查询结果(遍历)添加到成员信息表:
        public int addClothes() {
            ArrayList<ApplyforClo> arr = null;
            int row = 0;
            try {
                arr = getClothesDao.applyforClo();
                for (ApplyforClo a : arr) {
                    row = getClothesDao.addClothes(a.getCclothes(), a.getPid(), a.getCscore());
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
            return row;
        }
  • 相关阅读:
    poj 1222 EXTENDED LIGHTS OUT (高斯消元 )
    poj 2187 Beauty Contest (凸包: 最远点对,最长直径 , 旋转卡壳法)
    poj 1408 Fishnet (几何:线段相交 + 叉积 求面积 )
    poj 1228 Grandpa's Estate ( 凸包 )
    高斯消元 模版
    poj 1830 开关问题 (高斯消元 )
    poj 1113 Wall (凸包:周长)
    旋转卡壳算法
    poj 1681 Painter's Problem (高斯消元 )
    字符串相关处理
  • 原文地址:https://www.cnblogs.com/21-forever/p/11025300.html
Copyright © 2011-2022 走看看