Java高校教务系统
LIiuxb 人气:0需求:建立一个教务管理系统,为学生和教师提供不同的功能
//简单利用javase基础做出后端框架,后期再利用mysql数据库以及Spring cloud完善
父类:
public class people { private String name; private int age; private String sex; public people() { } public people(String name, int age, String sex) { this.name = name; this.age = age; this.sex = sex; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } }
学生类:
public class student extends people{ private String classname; private String studyid; private String chengji=""; private String kebiao=""; private String jiguo=""; private String studypassword; public student() { } public student(String name, int age, String sex, String classname, String studyid, String studypassword) { super(name, age, sex); this.classname = classname; this.studyid = studyid; this.studypassword = studypassword; } public String getClassname() { return classname; } public void setClassname(String classname) { this.classname = classname; } public String getStudyid() { return studyid; } public void setStudyid(String studyid) { this.studyid = studyid; } public String getStudypassword() { return studypassword; } public void setStudypassword(String studypass) { this.studypassword = studypassword; } public String getChengji() { return chengji; } public void setChengji(String chengji) { this.chengji = chengji; } public String getKebiao() { return kebiao; } public void setKebiao(String kebiao) { this.kebiao = kebiao; } public String getJiguo() { return jiguo; } public void setJiguo(String jiguo) { this.jiguo = jiguo; } }
教师类:
public class teacher extends people{ private String teachclass; private String teachid; private String teachpassword; public teacher() { } public teacher(String name, int age, String sex, String teachclass, String teachid, String teachpassword) { super(name, age, sex); this.teachclass = teachclass; this.teachid = teachid; this.teachpassword = teachpassword; } public String getTeachclass() { return teachclass; } public void setTeachclass(String teachclass) { this.teachclass = teachclass; } public String getTeachid() { return teachid; } public void setTeachid(String teachid) { this.teachid = teachid; } public String getTeachpassword() { return teachpassword; } public void setTeachpassword(String teachpassword) { this.teachpassword = teachpassword; } }
源码:
import java.util.ArrayList; import java.util.Random; import java.util.Scanner; public class test { public static void main(String[] args) { ArrayList<student> students = new ArrayList<>(); ArrayList<teacher> teachers = new ArrayList<>(); main(teachers,students); end(); } public static void main(ArrayList<teacher>teachers,ArrayList<student>students) { Scanner sc = new Scanner(System.in); System.out.println("----------欢迎来到中彬教育后台管理系统-----------"); while (true) { System.out.println("请输入您的身份:1.老师 2.学生 或者按0退出系统"); int commend = sc.nextInt(); switch (commend) { case 1: teach(students,teachers,sc); break; case 2: student(students,sc); break; case 0: return; default: System.out.println("输入不合法!请重新输入,或按0退出"); } } } public static void teach(ArrayList<student>students,ArrayList<teacher>teachers,Scanner sc) { System.out.println("----------欢迎进入教师界面----------"); while (true) { System.out.println("请选择您的操作:"); System.out.println("1.教师登录"); System.out.println("2.教师注册"); System.out.println("3.返回"); int commend = sc.nextInt(); switch (commend) { case 1: teacherdenglu(students,teachers,sc); break; case 2: teacherzhuce(teachers,sc); break; case 3: return; default: System.out.println("不存在该功能!"); } } } public static void student( ArrayList <student> students ,Scanner sc) { System.out.println("----------欢迎进入学生界面----------"); while (true) { System.out.println("请选择您的操作:"); System.out.println("1.学生登录"); System.out.println("2.学生注册"); System.out.println("3.返回"); int commend = sc.nextInt(); switch (commend) { case 1: studentdenglu(students,sc); break; case 2: studentzhuce(students,sc); break; case 3: return; default: System.out.println("不存在该功能!"); } } } public static void studentdenglu(ArrayList<student>students,Scanner sc) { System.out.println("----------欢迎进入学生登录系统----------"); String studyid; String password; String code; String code2 =yanzhengma(); if(students.size()==0) { System.out.println("系统中无学生信息!,请先注册学生账户"); } else { while (true) { System.out.println("请输入学号:"); studyid = sc.next(); student acc =getstudyid(studyid,students); if(acc!=null) { System.out.println("请输入密码:"); password= sc.next(); if(password.equals(acc.getStudypassword())) { System.out.println("请输入验证码"); System.out.println(code2); code= sc.next(); if(code.equals(code2)) { System.out.println("登录成功!,进入学生"+acc.getName()+"的主页"); studentmain(students,sc,acc); return; } else { System.out.println("验证码输入错误!"); } } else { System.out.println("密码错误!"); } } else { System.out.println("不存在该学号!"); } } } } public static void studentmain(ArrayList<student>students,Scanner sc,student s) { while (true) { System.out.println("----------学生"+s.getName()+"的主页----------"); System.out.println("选择操作:"); System.out.println("1.查询基本信息"); System.out.println("2.查询成绩"); System.out.println("3.查询课表"); System.out.println("4.查询记过"); System.out.println("5.注销"); System.out.println("6.退出系统"); System.out.println("7.修改密码"); int commend= sc.nextInt(); switch (commend) { case 1: student1(students,s); break; case 2: student2(students,s); break; case 3: student3(students,s,sc); break; case 4: student4(students,s); break; case 5: over(sc,students,s); break; case 6: return; case 7: xiugai(students,s,sc); default: System.out.println("不存在该功能!"); } } } public static void teachmain(ArrayList<student>students,ArrayList<teacher>teachers,Scanner sc ,teacher t) { while (true) { System.out.println("----------教师"+t.getName()+"的主页-----------"); System.out.println("选择操作:"); System.out.println("1.基本信息"); System.out.println("2.教学课程"); System.out.println("3.添加成绩"); System.out.println("4.添加课表"); System.out.println("5.添加记过"); System.out.println("6.注销"); System.out.println("7.退出系统"); System.out.println("8.修改密码"); int commend = sc.nextInt(); switch (commend) { case 1: teach1(teachers,t); break; case 2: teach2(teachers,t,sc); break; case 3: teach3(students,sc); break; case 4: teach4(students,sc); break; case 5: teach5(students,sc); break; case 6: over2(sc,teachers,t); break; case 7: return; case 8: xiugai2(teachers,t,sc); break; default: System.out.println("功能不存在!"); break; } } } public static void studentzhuce(ArrayList<student>students,Scanner sc) { System.out.println("----------欢迎进入学生注册系统----------"); System.out.println("请输入您的姓名:"); String name = sc.next(); System.out.println("请输入年龄:"); int age = sc.nextInt(); String sex; while (true) { System.out.println("请输入性别:"); sex = sc.next(); if (sex.equals("男") || sex.equals("女")) { break; } else System.out.println("性别输入不合法!请重新输入"); } System.out.println("请输入班级名:"); String classname = sc.next(); while (true) { System.out.println("请输入学号:"); String studyid = sc.next(); String password; while (true) { System.out.println("请输入密码:"); password = sc.next(); System.out.println("请再次输入密码:"); String password2 = sc.next(); if (password.equals(password2)) { break; } else { System.out.println("两次输入密码不一致!请重新输入!"); } } student s = new student(name, age, sex, classname, studyid, password); System.out.println("您的信息如下:"); System.out.println(classname + "\t\t\t" + studyid + "\t\t\t" + name + "\t\t\t" + age + "\t\t\t" + sex); students.add(s); break; } } private static void teacherdenglu(ArrayList<student>students,ArrayList<teacher>teachers,Scanner sc) { System.out.println("----------欢迎进入教师登录系统----------"); String teachid; String password; String code; String code2 =yanzhengma(); if(teachers.size()==0) { System.out.println("系统中无教师信息!,请先注册账户"); } else { while (true) { System.out.println("请输入职工号:"); teachid = sc.next(); teacher acc =getteachid(teachid,teachers); if(acc!=null) { System.out.println("请输入密码:"); password= sc.next(); if(password.equals(acc.getTeachpassword())) { System.out.println("请输入验证码"); System.out.println(code2); code= sc.next(); if(code.equals(code2)) { System.out.println("登录成功!,进入教师"+acc.getName()+"的主页"); teachmain(students,teachers,sc,acc); return; } else { System.out.println("验证码输入错误!"); } } else { System.out.println("密码错误!"); } } else { System.out.println("不存在该职工号!"); } } } } private static void teacherzhuce(ArrayList<teacher>teachers,Scanner sc) { System.out.println("----------欢迎进入教师注册系统----------"); System.out.println("请输入您的姓名:"); String name = sc.next(); System.out.println("请输入年龄:"); int age = sc.nextInt(); String sex; while (true) { System.out.println("请输入性别:"); sex = sc.next(); if (sex.equals("男") || sex.equals("女")) { break; } else System.out.println("性别输入不合法!请重新输入"); } System.out.println("请输入教学班级名:"); String teacherclass = sc.next(); while (true) { System.out.println("请输入职工号:"); String teachid = sc.next(); String password; while (true) { System.out.println("请输入密码:"); password = sc.next(); System.out.println("请再次输入密码:"); String password2 = sc.next(); if (password.equals(password2)) { break; } else { System.out.println("两次输入密码不一致!请重新输入!"); } } teacher s = new teacher(name, age, sex, teacherclass, teachid, password); System.out.println("您的信息如下:"); System.out.println(teacherclass + "\t\t\t" + teachid + "\t\t\t" + name + "\t\t\t" + age + "\t\t\t" + sex); teachers.add(s); break; } } public static void student1(ArrayList<student>students,student s) { System.out.println("----------基本信息----------"); System.out.println("学生姓名:"+s.getName()); System.out.println("学生班级:"+s.getClassname()); System.out.println("学生学号:"+s.getStudyid()); System.out.println("学生年龄:"+s.getAge()); System.out.println("学生性别:"+s.getSex()); } public static void student2(ArrayList<student>students,student s) { System.out.println("学生"+s.getName()+"的成绩查询"); System.out.println("科目"+"\t\t\t"+"成绩"+"\t\t\t"+"绩点"); System.out.println(s.getChengji()); } public static void student3(ArrayList<student>students,student s,Scanner sc) { System.out.println("课表查询:"); System.out.println("班级"+s.getClassname()+"的"+"课表为"); System.out.println(s.getKebiao()); } public static void student4(ArrayList<student>students,student s) { System.out.println("----------记过查询----------"); System.out.println(s.getName()+"的记过为"+s.getJiguo()+"\n"); } public static void over(Scanner sc,ArrayList<student>students,student s) { System.out.println("是否确认注销账户?按1确认,按2取消注销"); int tf = sc.nextInt(); if (tf == 1) { students.remove(s); System.out.println("注销成功!"); } else { System.out.println("取消注销"); } } public static void over2(Scanner sc,ArrayList<teacher>teachers,teacher s) { System.out.println("是否确认注销账户?按1确认,按2取消注销"); int tf = sc.nextInt(); if (tf == 1) { teachers.remove(s); System.out.println("注销成功!"); } else { System.out.println("取消注销"); } } public static void teach1(ArrayList<teacher>teachers,teacher s) { System.out.println("----------基本信息----------"); System.out.println("教师名称:"+s.getName()); System.out.println("教师年龄:"+s.getAge()); System.out.println("教师性别:"+s.getSex()); System.out.println("教师职工号:"+s.getTeachid()); System.out.println("教师教学班级:"+s.getTeachclass()); } public static void teach2(ArrayList<teacher>teachers,teacher s,Scanner sc) { System.out.println("----------教学课程----------"); System.out.println(s.getTeachclass()); System.out.println("添加请按1,修改请按2,退出按0"); int commend = sc.nextInt(); switch (commend) { case 1: System.out.println("输入要添加的课程:"); String addclass = sc.next(); s.setTeachclass(addclass+","+s.getTeachclass()); System.out.println("修改成功!新课程是"+s.getTeachclass()); break; case 2: System.out.println("输入要修改后的课程:"); String newclass =sc.next(); s.setTeachclass(newclass); System.out.println("修改成功!新课程是"+s.getTeachclass()); break; case 0: return; default: System.out.println("功能不存在!"); } } public static void teach3(ArrayList<student>students,Scanner sc) { System.out.println("----------添加成绩----------"); while (true) { System.out.println("请输入学生学号:"); String tostudyid = sc.next(); student tf = getstudyid(tostudyid, students); if (tf != null) { for (int i = 0; i < students.size(); i++) { student c = students.get(i); if (c.getStudyid().equals(tostudyid)) { System.out.println("输入课程名称:"); String kecheng = sc.next(); System.out.println("输入成绩:"); double score = sc.nextDouble(); System.out.println("输入绩点:"); double jidian =sc.nextDouble(); String chengji=kecheng+"\t\t\t"+score+"\t\t\t"+jidian; c.setChengji(c.getChengji()+"\n"+chengji); System.out.println("添加成功!"); System.out.println("继续添加按1,退出添加按0"); int commend=sc.nextInt(); switch (commend) { case 1: break; case 0: return; } } } } else { System.out.println("学生不存在!"); return; } } } public static void teach4(ArrayList<student>students,Scanner sc) { System.out.println("----------添加课表----------"); System.out.println("请输入班级名称:"); String banji= sc.next(); student acc=getclass(banji,students); if(acc!=null) { System.out.println("请输入年级:1.大一上 2.大一下 3.大二上 4.大二下 5.大三上 6.大三下"); String commend=sc.next(); System.out.println("班级"+acc.getClassname()+"的"+commend+"课表为"); teachtuo(students,acc,sc); } else System.out.println("班级不存在!"); } public static void teachtuo(ArrayList<student>students,student s ,Scanner sc) { System.out.println("请输入星期:1,2,3,4,5"); int commend = sc.nextInt(); System.out.println("请输入1-2节:"); String sub12 = sc.next(); System.out.println("请输入3-4节:"); String sub34= sc.next(); System.out.println("请输入5-6节:"); String sub56=sc.next(); System.out.println("请输入7-8节:"); String sub78=sc.next(); String newkebiao ="星期"+commend+":\t\t"+sub12+"\t\t"+sub34+"\t\t"+sub56+"\t\t"+sub78; s.setKebiao(newkebiao+s.getKebiao()); } public static void teach5(ArrayList<student>students,Scanner sc) { System.out.println("----------添加记过----------"); while (true) { System.out.println("请输入学生学号:"); String tostudyid = sc.next(); student tf = getstudyid(tostudyid, students); if (tf != null) { for (int i = 0; i < students.size(); i++) { student c = students.get(i); if (c.getStudyid().equals(tostudyid)) { System.out.println("输入记过:"); String ji = sc.next(); c.setJiguo(tf.getJiguo()+ji); System.out.println("添加成功!"); System.out.println("继续添加按1,退出添加按0"); int commend=sc.nextInt(); switch (commend) { case 1: break; case 0: return; } } } } else { System.out.println("学生不存在!"); return; } } } private static String yanzhengma() { Random r = new Random(); String ku ="0123456789"; String code=""; for (int i = 0; i < 4; i++) { int index = r.nextInt(ku.length()); char c = ku.charAt(index); code+=c; } return code; } //查询班级是否存在 public static student getclass(String classname,ArrayList<student>students) { for (int i = 0; i < students.size(); i++) { student s =students.get(i); if(s.getClassname().equals(classname)) { return s; } } return null; } //查询学生账户是否存在 private static student getstudyid(String studyid,ArrayList<student>students) { for (int i = 0; i < students.size(); i++) { student s = students.get(i); if (s.getStudyid().equals(studyid)) { return s; } } return null; } //查询教师账户是否存在 public static teacher getteachid(String teachid,ArrayList<teacher>teachers) { for (int i = 0; i < teachers.size(); i++) { teacher s =teachers.get(i); if(s.getTeachid().equals(teachid)) { return s; } } return null; } public static void xiugai(ArrayList<student>students , student s,Scanner sc) { System.out.println("修改密码操作"); while (true) { System.out.println("请输入原密码"); String oldpassword = sc.next(); if (oldpassword.equals(s.getStudypassword())) { System.out.println("请输入新密码:"); String newpassword= sc.next(); System.out.println("请再次输入新密码:"); String newpassword2= sc.next(); if(newpassword.equals(newpassword2)) { System.out.println("修改成功!"); s.setStudypassword(newpassword); return; } else System.out.println("两次密码不一致!请重新修改!"); } else { System.out.println("原密码错误!"); return; } } } public static void xiugai2(ArrayList<teacher>teachers , teacher s,Scanner sc) { System.out.println("修改密码操作"); while (true) { System.out.println("请输入原密码"); String oldpassword = sc.next(); if (oldpassword.equals(s.getTeachpassword())) { System.out.println("请输入新密码:"); String newpassword= sc.next(); System.out.println("请再次输入新密码:"); String newpassword2= sc.next(); if(newpassword.equals(newpassword2)) { System.out.println("修改成功!"); s.setTeachpassword(newpassword); return; } else System.out.println("两次密码不一致!请重新修改!"); } else { System.out.println("原密码错误!"); return; } } } public static void end() { System.out.println("已退出系统!欢迎下次进入"); } }
加载全部内容