教室管理系统(java语言) 后端 - Java

教室管理系统(java语言) 后端 - Java

《Java编程基础课程设计》课程设计报告

   教室管理系统

    

    

  

    

课程设计时间:

软件工程 专业Java编程基础课程设计任务书

学生姓名 专业班级 学号 
题 目教室管理系统
课题性质工程设计课题来源自拟课题
指导教师 同组姓名
主要内容假定有n个教学楼,每个楼有不同的教室,每个教室座位数不同,每个教室的类型不同(多媒体教室、非多媒体教室,智慧教室)功能要求:能够对教学楼、教室信息进行增、改、查、浏览;教师根据需要按照条件进行教室查询;教师根据需要进行申请教室使用。
任务要求(1)能够将课本上的理论知识和实际问题有机的结合起来,掌握分析和解决实际工程问题的方法和能力;(2)能够按照设计题目要求进行方案设计和实现;在设计实现中能够体现良好的身心素质和团队;(3)在答辩过程中要求具有良好的表达能力,专业的描述方法,并能进行良好的沟通和交流;(4)撰写课程设计报告,包含需求分析、概要设计、运行环境、开发工具、详细设计、调试分析、测试结果等内容,给出系统的用例图、时序图和类图。文字、段落和图表格式规范。
参考文献[1]《Java8程序设计及实验》. 刘继承等. 清华大学出版社,2018.[2] Java从入门到精通(第5版).明日科技. 清华大学出版社,2019[3]《Java核心技术卷I:基础知识》(第10版)(英文影印版),(美)Cay S. Horstmann、Gary Cornell,人民邮电出版社,2016[4] 《Core Java Volume II: Advanced Features》(10th Edition). Cay S. Horstmann, Gary Cornell. Prentice Hall, 2016.
审查意见教研室主任签字: 2022年 5月 27日

目录

1 需求分析11.1.1 产品概述11.1.2 产品面向的用户群体11.1.3 产品范围11.1.4 产品中的角色11.2 产品的可行性分析11.2.1 技术可行性分析11.2.2 经济可行性分析11.2.3 操作可行性分析12 概要设计13 运行环境44 开发工具和编程语言45 详细设计55.1数据库设计55.2类的设计85.3登录125.4主界面165.5管理员增加195.6修改225.7查询265.8删除275.8浏览316 系统测试316.1登录模块316.2教室查询33336.3申请教室34346.4撤销申请366.4我的申请377 心得体会388 参考文献39

1 需求分析

1.1.1 产品概述

该系统基于大学学校的教室管理而研发,满足学校对于教室的管理和教师用户的申请,可以很好满足教师用户体验。

1.1.2 产品面向的用户群体

在校教师。

1.1.3 产品范围

用户类型:教师用户、管理员

语言版本:中文

1.1.4 产品中的角色

经过分析,最终从本系统中提取出两种角色,即:教师用户和管理者。而各种角色及其职责如表1-1所示。

表1-1 角色表

角色名称职责描述
管理员系统管理员的主要职责是从系统后台维护系统,如管理教师信息、管理系统等。
教师用户用户拥有查询教室、申请教室、撤销申请、我的申请等功能

1.2 产品的可行性分析

1.2.1 技术可行性分析

  • 本项目计划使用基于Java知识,MySQL数据库、jdbc、接口等知识进行开发,优点如下:

1.成本低,可操作性强。

2.节省开发时间,可以在较短的时间内完成系统的研发与实现。

3.良好的扩展性,可以在后期更新版本时增加新的功能,增强用户体验性。

4.良好的可维护性,可以很好的对系统进行维护。

1.2.2 经济可行性分析

经济可行性:

1.搭建此类小型系统和维护的成本较低,百元左右即可满足搭建需求,对于校内大学生来说可以接受。

2.学校使用需要缴纳一定费用。

1.2.3 操作可行性分析

1.操作简单,只需要动动鼠标,便可以进行申请教室。

3.界面美观通俗易懂,简单明了,极易上手。

2 概要设计

系统用例图如图2.1所示:

图2.1 用例图

时序图如下:

图2.2 登录时序图

图2.3 教师申请教室时序图

图2.4 管理员查询时序图

3 运行环境

(1)硬件环境: PC机 内存 16G

(2)软件环境:操作系统:Window10

4 开发工具和编程语言

(1)开发环境:IDEA、DataGrip 数据库:Mysql

(2)编程语言:Java语言


5 详细设计

5.1数据库设计

5.1.1数据库各表之间的关系:

5.1.2数据库表结构设计

教室信息表(classroom):

属性名称数据类型属性描述
classroomidint教室编号
typeVarchar(20),允许有空值教室类型
numint教室座位数
statusInt,默认为0教室是否被申请(0未申请1已申请)
reasonVarchar(20),默认为“null”申请原因
floor_nameVarchar(20)所属楼层
user_nameVarchar(20) ,默认为“null申请教师姓名
user_idint申请教师id
floor_idint所属楼层id

教学楼表(floor)

属性名称数据类型属性描述
idInt,自动增长,唯一教学楼id
nameVarchar(20),默认为“null”教学楼名称

教师表(user)

属性名称数据类型属性描述
idInt,自动增长,唯一教师id
nameVarchar(20)教师姓名
numberVarchar(20)教师工号
passwordVarchar(20)教师密码
statusInt,默认为0教师权限(0普通用户1管理员)

数据库Er图:

图5.1教师er图

图5.2教学楼er图

图5.3教室er图

5.2类的设计

Information包下的类图:

ServiceImpl包下的接口和实现类之间的关系:

Utils包下的类图:

5.3登录

登录界面具有登录和注册两个功能,注册时教师需要输入相关的信息,会根据工号在数据库中判断用户是否已注册,密码需要输入两次,UserService接口中checkpassword方法判断两次密码是否一致,然后再UserService接口中有saveuser方法将数据保存再数据库中,登录功能中会根据用户的工号去判断是管理员登录还是普通用户登录,根据这展示不同的界面,登录中会判断输入的信息是否有误,从而给出提示,正确则登录成功,否则登录失败。

5.3.1用户注册

public static User first(){
Scanner sc = new Scanner(System.in);
User user = new User();
while (true) {
System.out.print("请输入教师姓名:");
user.setName(sc.nextLine());
System.out.print("请输入教师工号:");
String number = sc.nextLine();
boolean bl = UserService.checkNumber(number);
if (bl == true){
user.setNumber(number);
break;
}else{
System.out.println("该用户已注册,请重新输入信息!");
}
}

5.3.2普通用户登录

public static User second(){
Scanner sc = new Scanner(System.in);
User user = new User();
System.out.print("请输入教师工号:");
user.setNumber(sc.nextLine());
System.out.print("请输入教师密码:");
user.setPassword(sc.nextLine());
return user;
}

public static void third(int status,User user){
if(status == 2){
System.out.println("用户输入信息有误,登录失败!");
return;
}else{
if(status == 0){
loginuser = user;
System.out.println("普通用户登录成功!");
fifth();
}else{
System.out.println("管理员登录成功!");
fouth();
}
}
}

5.3.3管理员登录

5.3.4登录失败

关键代码:

public static void third(int status,User user){
if(status == 2){
System.out.println("用户输入信息有误,登录失败!");
return;
}else{
if(status == 0){
loginuser = user;
System.out.println("普通用户登录成功!");
fifth();
}else{
System.out.println("管理员登录成功!");
fouth();
}
}
}

5.4主界面

管理员:

5.4.1管理员界面

public static void fouth(){
while (true) {
UiUtils.second();
Scanner sc = new Scanner(System.in);
String comoand = sc.nextLine();
switch (comoand) {
/*增加*/
case "1":
sixth();
break;
/*修改 */
case "2":
Twenty_fourth();
break;
/*查询*/
case "3":
ninth();
break;
/*删除*/
case "4":
twentieth();
break;
/*浏览*/
case "5":
twenty_third();
break;
case "6":
return;
default:
System.out.println("你输入的命令不存在!");
}
}

}

教师用户主界面:

5.4.2管理员界面

public static void fifth(){
while (true) {
UiUtils.third();
Scanner sc = new Scanner(System.in);
String comoand = sc.nextLine();
switch (comoand) {
/*教室查询*/
case "1":
twelfth();
break;
/*申请教室*/
case "2":
thirteenth();
break;
/*撤销申请*/
case "3":
seventeenth();
break;
/*我的申请*/
case "4":
sixteenth(loginuser);
break;
case "5":
return;
default:
System.out.println("你输入的命令不存在!");
}
}
}

5.5管理员增加

5.5.1增加楼层

5.5.1 管理员增加楼层

private static Floor seventh() {
Floor floor = new Floor();
Scanner sc = new Scanner(System.in);
while (true) {
System.out.printf("请输入楼层名称:");
String floor1 = sc.nextLine();
boolean is = FloorService.judgefloor(floor1);
if(is){
floor.setName(floor1);
break;
}else{
System.out.println("该楼层学校已有!");
}
}
return floor;
}

5.5.2增加教室

5.5.2管理员增加教室

private static Classroom eighth() {
Classroom classroom = new Classroom();
Scanner sc = new Scanner(System.in);
while (true) {
System.out.printf("请输入教室名称(形如 101 的数字):");
String id = sc.nextLine();
boolean is = id.matches("[0-9]+");
if(is == true){
int classroomid = Integer.parseInt(id);
classroom.setClassroomid(classroomid);
System.out.printf("请输入教室类型:");
classroom.setType(sc.nextLine());
while (true) {
System.out.printf("请输入教室座位数(形如 40 的数字):");
String num = sc.nextLine();
boolean is1 = num.matches("[0-9]+");
if(is1 == true){
int num1 = Integer.parseInt(num);
classroom.setNum(num1);
break;
}else {
System.out.println("输入不是数字!");
}
}
while (true) {
System.out.printf("请输入教室所在楼层(输入楼层名称即可):");
String floor = sc.nextLine();
boolean is2 = FloorService.judgefloor(floor);
if(is2 == true){
System.out.println("学校没有该楼!");
}else{
int flag = 0;
boolean is3 = ClassRoomService.judgeClass(floor,classroomid);
if(is3 == true){
flag = 1;
System.out.println("+--"+floor+"--+已有这间教室!");
}else{
classroom.setFloor_name(floor);
}
if(flag == 0){
break;
}
}
}
break;
}else{
System.out.println("输入不是数字!");
}
}
return classroom;
}

5.6修改

5.6.1修改类型

5.6.1 管理员修改类型

private static void twenty_fifth() {
twenty_third();
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("请输入操作(按1.继续 0.返回)编号:");
String command = sc.nextLine();
switch (command){
case "1":
while (true) {
System.out.printf("输入楼层:");
String floor = sc.nextLine();
boolean is = FloorService.judgefloor(floor);
if(is == true){
System.out.println("学校没有该楼!");
}else{
while (true) {
int classroomid;
while (true) {
System.out.printf("输入教室名称(形如 101 的数字):");
String id = sc.nextLine();
boolean is1 = id.matches("[0-9]+");
if (is1 == true){
classroomid = Integer.parseInt(id);
break;
}else {
System.out.println("输入不是数字!");
}
}
boolean is2 = ClassRoomService.judgeClass(floor,classroomid);
if(is2 == true){
System.out.printf("输入要修改为的类型:");
String type = sc.nextLine();
ClassRoomService.updateType(floor,classroomid,type);
System.out.println("修改教室类型成功!");
break;
}else {
System.out.println("+--"+floor+"--+没有这间教室!");
}
}
break;
}
}
break;
case "0":
return;
default:
System.out.println("你输入的命令不存在!");
}
}
}

5.6.2修改教室可容纳人数

5.6.2 管理员修改教室可容纳人数

private static void twenty_sixth() {
twenty_third();
Scanner sc = new Scanner(System.in);
while (true) {
System.out.printf("按 1 继续 0 返回:");
String command = sc.nextLine();
switch (command){
case "1":
while (true) {
System.out.printf("输入楼层:");
String floor = sc.nextLine();
boolean is = FloorService.judgefloor(floor);
if(is == true){
System.out.println("学校没有该楼!");
}else{
while (true) {
int classroomid;
while (true) {
System.out.printf("输入教室名称(形如 101 的数字):");
String id = sc.nextLine();
boolean is1 = id.matches("[0-9]+");
if (is1 == true){
classroomid = Integer.parseInt(id);
break;
}else {
System.out.println("输入不是数字!");
}
}
boolean is2 = ClassRoomService.judgeClass(floor,classroomid);
if(is2 == true){
while (true) {
System.out.printf("输入要修改为的可容纳人数(形如 40 的数字):");
String num = sc.nextLine();
boolean is3 = num.matches("[0-9]+");
int num1;
if (is3 ==true){
num1 = Integer.parseInt(num);
ClassRoomService.updateNum(floor,classroomid,num1);
System.out.println("修改教室可容纳人数成功!");
break;
}else{
System.out.println("输入的不是数字!");
}
}
break;
}else {
System.out.println("+--"+floor+"--+没有这间教室!");
}
}
break;
}
}
break;
case "0":
return;
default:
System.out.println("你输入的命令不存在!");
}
}
}

5.7查询

查询功能基本与普通用户的功能相似,管理员多了一个按教师查询,普通用户功能在6系统测试处有显示:

此处仅展示管理员按教师查询:

5.7.1 管理员按教师查询

private static int eleventh() {
Scanner sc = new Scanner(System.in);
int id;
while (true) {
System.out.printf("请输入教师名称:");
String user_name = sc.nextLine();
boolean is = UserService.judgeUser(user_name);
if(is == true){
System.out.println("学校没有该教师!");
}else{
id = UserService.printUser_id(user_name);
break;
}
}
return id;
}

5.8删除

5.8.1删除教学楼

删除教学楼应用场景为教学楼用作别的用处,不在用户教学,所以从系统中删除,同时也会删除该楼内的教室信息和教师们的申请:

5.8.1管理员删除楼层

private static void twenty_first() {
while (true) {
UiUtils.twelfth(FloorService.printFloor1());
Scanner sc = new Scanner(System.in);
System.out.println("请输入(1.继续 0.返回)编号:");
String command = sc.nextLine();
switch (command){
case "1":
while (true) {
System.out.printf("请输入楼层名称:");
String floor_name = sc.nextLine();
boolean is = FloorService.judgefloor(floor_name);
if(is == true){
System.out.println("学校没有该楼!");
}else{
FloorService.deleteClass(floor_name);
FloorService.deleteFloor(floor_name);
System.out.println("删除楼层成功!");
break;
}
}
break;
case "0":
return;
default:
System.out.println("你输入测命令不存在!");
}
}
}

5.8.2删除教师申请

5.8.2管理员删除教师申请

private static void twenty_second() {
Scanner sc = new Scanner(System.in);
while (true) {
UiUtils.nineteenth(UserService.printUser());
System.out.println("请输入操作(1.继续 0.返回)编号:");
String command = sc.nextLine();
switch (command){
case "1":
while (true) {
System.out.printf("请输入教师名称:");
String user_name = sc.nextLine();
boolean is = UserService.judgeUser(user_name);
if(is == true){
System.out.println("学校没有该教师!");
}else{
List<Classroom> list = UserService.printClass(user_name);
if(list.size() == 0){
System.out.println("+--"+user_name+"--+没有申请教室!");
}else{
UiUtils.twentieth(UserService.printClass(user_name),user_name);
while (true) {
System.out.printf("请输入要删除申请的教学楼名称:");
String floor = sc.nextLine();
boolean is1 = FloorService.judgeUserFloor(floor);
if(is1 == true){
while (true) {
int flag = 0;
System.out.printf("请输入要删除申请的教室名称(形如 101 的数字):");
String id = sc.nextLine();
boolean is2 = id.matches("[0-9]+");
int id1;
if(is2 == true){
id1 = Integer.parseInt(id);
boolean is3 = ClassRoomService.judgeUserClass(user_name,floor,id1);
if(is3 == true){
flag = 1;
ClassRoomService.deleteClassRoom(floor,id1);
System.out.println("删除教师申请成功!");
break;
}else{
System.out.println("+--"+user_name+"--在--"+floor+"--下没有申请--"+id1+"--教室--+");
}
if(flag == 1){
break;
}
}else {
System.out.println("输入不是数字!");
}
}
break;
}else {
System.out.println("+--"+user_name+"没有在该教学楼下申请教室!");
}
}
}
break;
}
}
break;
case "0":
return;
default:
System.out.println("你输入的命令不存在");
}
}
}

5.8浏览

private static void twenty_third() {
List<Mix> list = ClassRoomService.printMix();
UiUtils.sixth(list);
}

6 系统测试

6.1登录模块

用户登录:

6.2教室查询

6.3申请教室

6.4撤销申请

6.4我的申请

7 心得体会

通过这次java设计,对我的项目教室管理系统进行了架构设计、时序图分析、类图设计、数据库设计等,深切体会到了整个项目全流程操作。该系统实现了用户查询,申请、我的申请,撤销申请等功能管理增删查改浏览等功能,后台数据库可以对用户的功能进行处理,同时给出响应。

问题:对一些时序图、用例图的绘制还不够熟练,通过查阅资料解决了这一问题。

同时增进了我对Java语言的运用熟练度,通过查询资料,学会了一些新的知识,受益匪浅,对于java中接口的编写是第一次用于实践整体的系统项目,过程中遇到了一些波折,比如将接口写在那个包下,后期逐渐写的时候逐渐意识到将所有接口和对于其的实现类写到一个包下便于管理,代码方面在编写时总体没有遇到啥问题,唯一的时输出表格信息时,总是对不齐,后来在网上查阅教程,别人都是写的大量方法来对齐输出,后来找到了一个比较简单的方法,例如,输出字符串%7s时后面加个制表符\t,就是%7s\t,这样能将其很好的对齐。

还有一个我有点卡壳的时sql语言中怎么将三张表连起来,在网上的看的教学sql的视频都是以连两张表为主,在网上查了大量资料后才逐渐搞懂了一些怎么将三张乃至更多表连起来的sql语句,还有一些就是子查询上面的问题,总体是sql简单的增删查改语句能熟练编写,一些联表的地方在datagrip中写了写能查询出来才去使用,算是对我有了一点进步。

8 参考文献

[1]刘继承等.Java 8程序设计及实验[M].清华大学出版社,2018.09

[2]耿祥义,张跃平.Java程序设计精编教程[M].清华大学出版社,2021.05

[3]张白一等.面向对象程序设计-java.西安电子科技大学出版社,2018.10

[4]明日科技.Java从入门到精通(第5版)[M].清华大学出版社,2019.03

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值