Java实现高校教务系统
作者:LIiuxb 时间:2022-05-16 04:24:17
本文实例为大家分享了Java实现高校教务系统的具体代码,供大家参考,具体内容如下
需求:建立一个教务管理系统,为学生和教师提供不同的功能
//简单利用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("已退出系统!欢迎下次进入");
}
}
来源:https://blog.csdn.net/m0_65726168/article/details/125794032
标签:Java,教务系统
0
投稿
猜你喜欢
java线程池:获取运行线程数并控制线程启动速度的方法
2022-06-30 23:22:57
Android实现颜色渐变动画效果
2022-05-31 09:52:53
springboot 自定义权限标签(tld),在freemarker引用操作
2023-11-23 06:20:15
详解C++设计模式编程中建造者模式的实现
2022-10-25 01:33:20
Android实现便于批量操作可多选的图片ListView实例
2021-07-17 19:24:54
IntelliJ IDEA中查看文件内所有已声明的方法(类似eclipse的outline)
2021-08-06 00:39:39
android商户扫码枪读取手机二维码
2023-11-09 12:58:24
c#获取两个特定字符之间的内容并输出的方法
2021-12-02 19:47:11
C#实现上位机与欧姆龙PLC通讯(FINS)
2022-10-05 03:10:08
Android 编程下字库的使用及注意事项
2021-09-23 13:37:59
Android运用onTouchEvent自定义滑动布局
2021-09-24 04:39:06
MyBatis图文并茂讲解注解开发多对多查询
2022-10-27 17:05:04
Android 6.0以上权限拒绝打开权限设置界面的解决方法
2021-11-07 01:59:35
Android实现的RecyclerView适配器
2023-07-12 23:02:21
Java定位问题线程解析
2023-08-09 22:04:27
基于Springboot+Junit+Mockito做单元测试的示例
2023-01-03 21:15:51
浅谈Maven镜像更换为阿里云中央仓库(精)
2022-08-06 04:48:17
C#使用随机数编写班级点名器的示例代码
2022-05-26 11:04:51
一文精通Java 多线程之全方位解读
2022-10-23 19:15:51
聊聊如何打印GC日志排查的问题
2023-01-22 22:10:56