public class ArrayListDemo {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        StudentsBiz stuBiz = new StudentsBiz();
        char flag = 'y';
        do {

            System.out.println("\t\t 学生管理系统");
            System.out.println("\t\t 1.增加学生信息");
            System.out.println("\t\t 2.修改学生信息");
            System.out.println("\t\t 3.查询学生信息");
            System.out.println("\t\t 4.删除学生信息");
            System.out.println("================================");
            System.out.println("请选择数字进行操作:");
            int which = sc.nextInt();
            String name = "";
            String age = "";
            String sex = "";
            String classes = "";
            Students stus = new Students();
            switch (which) {
            case 1:
                System.out.println("请输入学生姓名:");
                name = sc.next();
                System.out.println("请输入学生年龄:");
                age = sc.next();
                System.out.println("请输入学生性别:");
                sex = sc.next();
                System.out.println("请输入学生班级:");
                classes = sc.next();
                stus.setName(name);
                stus.setAge(age);
                stus.setSex(sex);
                stus.setClasses(classes);
                // 调用业务类的 添加学生方法
                stuBiz.addStu(stus);
                break;
            case 2:
                System.out.println("请输入学生姓名(姓名不可修改):");
                name = sc.next();
                System.out.println("请输入学生年龄:");
                age = sc.next();
                System.out.println("请输入学生性别:");
                sex = sc.next();
                System.out.println("请输入学生班级:");
                classes = sc.next();
                stus.setName(name);
                stus.setAge(age);
                stus.setSex(sex);
                stus.setClasses(classes);
                // 调用业务类的 添加学生方法
                stuBiz.updateStu(stus);
                break;
            case 3:
                List myList = stuBiz.getList();
                if(myList.size()>0){
                    System.out.println("\t姓名\t年龄\t性别\t班级");
                    System.out.println("=====================================");
                }
                for (int i = 0; i < myList.size(); i++) {
                    Students stu = (Students)myList.get(i);
                    System.out.print("\t"+stu.getName());
                    System.out.print("\t"+stu.getAge());
                    System.out.print("\t"+stu.getSex());
                    System.out.print("\t"+stu.getClasses());
                    System.out.print("\n");
                }
                break;
            case 4:
                System.out.println("请输入删除的学生姓名:");
                name = sc.next();
                stuBiz.deleteStu(name);
                break;

            default:
                break;
            }
            System.out.println("操作成功,是否继续(y/n)");
            flag = sc.next().charAt(0);
        } while (flag=='y');

    }
}