I’m coming!我又回来了,最近有点迷上java编程了,越编越来劲,哈哈哈哈。
奈何本人实力有限,新知识还没学明白,这次还是只是用了类的封装。
案例
嗯,流程就这样滴。
程序
测试类
class Test{
public static void main(String[] args){
StudentSystem ss = new StudentSystem();
ss.menu();
}
}
学生管理系统
class StudentSystem{
// 学生管理系统类
Scanner input = new Scanner(System.in);
User[] user = new User[3];
Student[] stu = new Student[5];
//Clazz[] clazz = new Clazz[2]
int count; // 计数有效用户个数
int post; // 存储成功登录用户下标
int countStu; //计数有效学生个数
public StudentSystem(){
}
public void init(){
//初始化
user[0] = new User("202001","123456","110");
user[1] = new User("202002","123123","111");
user[2] = new User("202003","123321","112");
count = 3;
stu[0] = new Student("200101","123456","金子",'女',22,88.8,"2020-01");
stu[1] = new Student("200102","123456","叶子",'男',23,66.6,"2020-01");
stu[2] = new Student("200103","123456","二傻",'女',22,55.5,"2020-01");
stu[3] = new Student("200201","123456","小黑",'男',22,77.7,"2020-02");
stu[4] = new Student("200202","123456","小白",'女',23,80.0,"2020-02");
countStu = 5;
}
public void menu(){
// 主菜单(登陆界面)
int select; //选择键
this.init(); // 初始化
do{
System.out.println("--------欢迎使用学生管理系统--------");
System.out.println("1.注册 2.登录 3.退出");
System.out.print("请输入您的操作选项: ");
select = input.nextInt();
switch(select){
case 1 : this.register();break;
case 2 : this.login();break;
case 3 : System.out.println(" 已退出,期待您的下次使用!");break;
default : System.out.println(" 输入有误,请重新输入\n");
}
}while(select != 3);
}
public void register(){
// 注册
System.out.println("\n---------注册---------");
System.out.print("请设置账号:");
String id = input.next();
boolean mark = true;
for(int i=0;i<user.length;i++){
if(user[i].getId().equals(id)){
System.out.println(" 账号已存在,请更换!");
mark = false;
return;