大家好,欢迎来到IT知识分享网。
退出系统.
package com.test.dormitory; //校园宿舍管理系统的设计与实现 public class TestApp { public static void main(String[] args) { Test test = new Test(); test.Achieve(); } }
package com.test.dormitory; import java.util.Scanner; public class Test { //注册用户用户名数组 private static String[] usernames = new String[10]; //注册用户密码数组 private static String[] passwords = new String[10]; //注册用户人数初始化 private static int userCount = 0; //宿舍管理员人数初始化 private static int adminCount = 0; private static int StudentNumber = 0; private static int D_Messages = 0; private static int D_B_Messages = 0; private static int Lack_Messages = 0; String key; Scanner scanner = new Scanner(System.in); meau Meau= new meau(); boolean loop=true; boolean a=true; boolean a1=true; boolean a2=true; boolean a3=true; boolean a4=true; boolean a5=true; boolean a6=true; administrators [] Administrators= new administrators[1000]; D_B_message [] d_B_message= new D_B_message[20]; D_message [] d_message= new D_message[1000]; StudentMessage [] studentMessage= new StudentMessage[10000]; StudentsLack [] studentsLack= new StudentsLack[]; // 用于存储登录用户名 String []user= new String[10]; //整体流程 public void Achieve(){ do { Meau.LoginMeau(); System.out.print("请选择:"); key=scanner.next(); switch (key){ case "1": //登录菜单 AchieveLogin(); A_Achieve(); break; case "2": AchieveRegister(); break; case "3": loop=false; break; default: System.out.println("输入错误,请重新输入"); } }while (loop); System.out.println("退出校园宿舍管理系统"); } //登录功能 public void AchieveLogin(){ do { System.out.print("请输入用户名:"); String scanner1 = scanner.next(); System.out.print("请输入密码:"); String scanner2 = scanner.next(); for (int i = 0; i < userCount; i++) { if (usernames[i].equals(scanner1)&&passwords[i].equals(scanner2)){ System.out.println("登录成功"); return; } System.out.println("用户名/密码错误,请重新输入"); } }while (a); } //注册功能 public void AchieveRegister(){ if (userCount>=10){ System.out.println("用户已满,无法注册"); return; } System.out.print("请输入用户名:"); String scanner3 = scanner.next(); for (int i = 0; i < userCount; i++) { if (usernames[i].equals(scanner3)){ System.out.println("用户名重复,请重新注册"); return; } } System.out.print("请输入密码:"); String scanner4 = scanner.next(); usernames[ userCount]=scanner3; passwords[ userCount]=scanner4; System.out.println("注册成功"); userCount++; } //对校园宿舍管理系统进行选择 public void A_Achieve(){ do { Meau.FunctionMeau(); System.out.printf("请选择:"); String key = scanner.next(); switch (key){ case "1": AdministratorsAchieve(); break; case "2": StudentAchieve(); break; case "3": D_B_Achieve(); break; case "4": D_mesages(); break; case "5": Lack_Achieve(); break; case "6": a1=false; break; default: System.out.println("输入错误,重新输入"); } }while (a1); } //宿舍管理员管理功能实现 public void AdministratorsAchieve(){ do { Meau.AdministratorsMeau(); System.out.print("请选择:"); key=scanner.next(); switch (key){ case "1": Addadministrators(); break; case "2": DeleteAdministrators(); break; case "3": LookupAdministrators(); break; case "4": ModifyAdministrators(); break; case "5": a2=false; break; default: System.out.println("输入错误,请重新输入"); } }while (a2); } //添加管理员用户 public void Addadministrators(){ if(adminCount>=10){ System.out.println("管理员已满,无法添加"); return; } for (int i = 0; i <= adminCount ; i++) { System.out.print("管理员名字:"); String ad1 = scanner.next(); System.out.print("ID:"); String ID1 = scanner.next(); System.out.print("手机号:"); int number1= scanner.nextInt(); System.out.print("负责宿舍楼:"); String position = scanner.next(); Administrators[i] = new administrators(ad1 ,ID1,number1,position); adminCount++; System.out.println("添加成功"); break; } } //删除管理员用户信息 public void DeleteAdministrators(){ System.out.print("请输入名字:"); String name = scanner.next(); for (int i = 0; i <adminCount ; i++) { if (Administrators[i] != null && Administrators[i].getName().equals(name)) { Administrators[i] = null; System.out.println(name+"删除成功"); adminCount--; break; } else { System.out.println("删除失败,管理员中没有该成员"); break; } } } //查找管理员信息 public void LookupAdministrators(){ System.out.print("请输入名字:"); String name = scanner.next(); for (int i = 0; i < adminCount; i++) { if (Administrators[i] != null && Administrators[i].getName().equals(name)) { System.out.println(Administrators[i]); return; } } System.out.println("没有查询到管理员信息"); } //修改管理员信息 public void ModifyAdministrators(){ System.out.print("请输入要修改管理员的名字:"); String name = scanner.next(); for (int i = 0; i < adminCount; i++) { if (Administrators[i] != null && Administrators[i].getName().equals(name)){ System.out.print("新管理员名字:"); String ad1 = scanner.next(); System.out.print("新ID:"); String ID1 = scanner.next(); System.out.print("新手机号:"); int number1= scanner.nextInt(); System.out.print("新负责宿舍楼:"); String position = scanner.next(); Administrators[i] = new administrators(ad1 ,ID1,number1,position); System.out.println("修改成功"); break; } } } //学生信息管理功能实现 public void StudentAchieve(){ do { Meau.StudentMeau(); System.out.print("请选择:"); key=scanner.next(); switch (key){ case "1": AddStudent(); break; case "2": deleteStudent(); break; case "3": LookupStudent(); break; case "4": ModifyStudent(); break; case "5": UpStudent(); break; case "6": a3=false; break; default: System.out.println("输入错误,请重新输入"); } }while (a3); } //添加学生信息 public void AddStudent(){ if(StudentNumber>=10000){ System.out.println("学生已满,无法添加"); return; } for (int i = 0; i <= StudentNumber ; i++) { System.out.print("学生名字:"); String ad1 = scanner.next(); System.out.print("手机号:"); int number1= scanner.nextInt(); System.out.print("寝室号:"); String position = scanner.next(); System.out.print("缺勤次数:"); String loce = scanner.next(); studentMessage[i] = new StudentMessage(ad1 ,number1,position,loce); StudentNumber++; System.out.println("添加成功"); break; } } // 删除学生信息、 public void deleteStudent(){ System.out.print("请输入名字:"); String name = scanner.next(); for (int i = 0; i <StudentNumber ; i++) { if ( studentMessage[i] != null && studentMessage[i].getName().equals(name)) { studentMessage[i] = null; System.out.println(name+"删除成功"); StudentNumber--; break; } else { System.out.println("删除失败,学生中没有该成员"); break; } } } // 查找学生信息、 public void LookupStudent(){ System.out.print("请输入名字:"); String name = scanner.next(); for (int i = 0; i <=StudentNumber; i++) { if (studentMessage[i] != null &&studentMessage[i].getName().equals(name)) { System.out.println(studentMessage[i]); return; } } System.out.println("没有查询到学生信息"); } // 修改学生信息、 public void ModifyStudent(){ System.out.print("请输入要修改学生的名字:"); String name = scanner.next(); for (int i = 0; i <=StudentNumber; i++) { if (Administrators[i] != null && Administrators[i].getName().equals(name)){ System.out.print("新学生名字:"); String ad1 = scanner.next(); System.out.print("新手机号:"); int number1= scanner.nextInt(); System.out.print("新寝室号:"); String position = scanner.next(); System.out.print("新缺勤次数:"); String loce = scanner.next(); studentMessage[i] = new StudentMessage(ad1 ,number1,position,loce); System.out.println("修改成功"); break; } } } // 导出学生信息 public void UpStudent(){ System.out.println("所有学生信息如下:"); for (int i = 0; i < StudentNumber; i++) { System.out.println(studentMessage[i]); } } //宿舍信息管理功能实现 public void D_mesages(){ do { Meau.DormitoryMeau(); System.out.print("请选择:"); key=scanner.next(); switch (key){ case "1": AddD(); break; case "2": DeleteD(); break; case "3": LoopupD(); break; case "4": ModifyD(); break; case "5": UpD(); break; case "6": a4=false; break; default: System.out.println("输入错误,请重新输入"); } }while (a4); } //添加宿舍信息 public void AddD(){ for (int i = 0; i <= 1000 ; i++) { System.out.print("寝室号:"); String ad1 = scanner.next(); System.out.print("寝室人数:"); String number1= scanner.next(); System.out.print("寝室长姓名:"); String name = scanner.next(); d_message[i] = new D_message(ad1 ,number1,name); D_Messages++; System.out.println("寝室信息添加成功"); break; } } // 删除宿舍信息、 public void DeleteD(){ System.out.print("请输入寝室号:"); String name = scanner.next(); for (int i = 0; i <1000 ; i++) { if ( d_message[i] != null && d_message[i].getId().equals(name)) { d_message[i] = null; D_Messages--; System.out.println(name+"寝室信息清空"); break; } else { System.out.println("清空失败,请输入正确寝室号"); break; } } } // 查找宿舍信息、 public void LoopupD(){ System.out.print("请输入寝室号:"); String name = scanner.next(); for (int i = 0; i <= D_Messages; i++) { if (d_message[i] != null &&d_message[i].getId().equals(name)) { System.out.println(d_message[i]); return; } } System.out.println("没有查询到寝室信息"); } // 修改宿舍信息、 public void ModifyD(){ System.out.print("请输入要修改的寝室号:"); String name = scanner.next(); for (int i = 0; i < 1000; i++) { if (d_message[i] != null && d_message[i].getId().equals(name)){ System.out.print("新寝室号:"); String ad1 = scanner.next(); System.out.print("新寝室人数:"); String number1= scanner.next(); System.out.print("新寝室长姓名:"); String name1 = scanner.next(); d_message[i] = new D_message(ad1 ,number1,name1); System.out.println("寝室信息更新成功"); break; } } } // 导出宿舍信息 public void UpD(){ System.out.println("所有寝室信息如下:"); for (int i = 0; i < D_Messages; i++) { System.out.println(d_message[i]); } } //宿舍楼信息管理功能实现 public void D_B_Achieve(){ do { Meau.AbsenteeismMeau(); System.out.print("请选择:"); key=scanner.next(); switch (key){ case "1": AddD_B(); break; case "2": DeleteD_B(); break; case "3": LoopupD_B(); break; case "4": ModifyD_B(); break; case "5": UpD_B(); break; case "6": a5=false; break; default: System.out.println("输入错误,请重新输入"); } }while (a5); } //添加宿舍楼信息 public void AddD_B() { for (int i = 0; i <=D_B_Messages ; i++) { System.out.print("宿舍楼号:"); String ad1 = scanner.next(); System.out.print("负责人:"); String number1= scanner.next(); System.out.print("房间数:"); String name = scanner.next(); d_B_message[i] = new D_B_message(ad1 ,number1,name); D_B_Messages++; System.out.println("寝室楼信息添加成功"); break; } } // 删除宿舍楼信息、 public void DeleteD_B(){ System.out.print("请输入宿舍楼号:"); String name = scanner.next(); for (int i = 0; i <=D_B_Messages ; i++) { if ( d_B_message[i] != null && d_B_message[i].getName().equals(name)) { d_B_message[i] = null; D_B_Messages--; System.out.println(name+"寝室楼信息清空"); break; } else { System.out.println("清空失败,请输入正确寝室号"); break; } } } // 查找宿舍楼信息、 public void LoopupD_B(){ System.out.print("请输入寝室楼号:"); String name = scanner.next(); for (int i = 0; i <=D_B_Messages; i++) { if (d_B_message[i] != null &&d_B_message[i].getName().equals(name)) { System.out.println(d_B_message[i]); } } System.out.println("没有查询到寝室信息"); } // 修改宿舍楼信息、 public void ModifyD_B(){ System.out.print("请输入要修改的寝室楼号:"); String name = scanner.next(); for (int i = 0; i <=D_B_Messages; i++) { if (d_B_message[i] != null && d_B_message[i].getName().equals(name)){ System.out.print("新寝室楼号:"); String ad1 = scanner.next(); System.out.print("新寝室楼负责人:"); String number1= scanner.next(); System.out.print("新房间数:"); String name1 = scanner.next(); d_B_message[i] = new D_B_message(ad1 ,number1,name1); System.out.println("寝室信息更新成功"); break; } } } // 导出宿舍楼信息 public void UpD_B(){ System.out.println("所有寝室楼信息如下:"); for (int i = 0; i <D_B_Messages; i++) { System.out.println(d_B_message[i]); } System.out.println("空"); } //缺寝记录功能实现 public void Lack_Achieve(){ do { Meau.AbsenteeismMeau(); System.out.print("请选择:"); key=scanner.next(); switch (key){ case "1": Lack_Record(); break; case "2": Delete_Recod(); break; case "3": Loopup_Recod(); break; case "4": a6=false; break; default: System.out.println("输入错误,请重新输入"); } }while (a6); } //增加学生缺寝记录 public void Lack_Record(){ for (int i = 0; i <=Lack_Messages; i++) { System.out.print("缺勤姓名:"); String name = scanner.next(); System.out.print("缺寝记录:"); String number1= scanner.next(); studentsLack[Lack_Messages++] = new StudentsLack(name,number1); System.out.println("缺勤信息添加成功"); break; } } //删除缺寝记录 public void Delete_Recod(){ System.out.print("请输入缺勤人姓名:"); String name = scanner.next(); for (int i = 0; i <=Lack_Messages ; i++) { if ( studentsLack[i] != null && studentsLack[i].getName().equals(name)) { studentsLack[i] = null; Lack_Messages--; System.out.println(name+"缺室信息清空"); break; } else { System.out.println("清空失败,请输入正确缺勤人姓名"); break; } } } //查询学生缺寝记录 public void Loopup_Recod(){ System.out.print("请输入缺勤人姓名:"); String name = scanner.next(); for (int i = 0; i <=Lack_Messages; i++) { if (studentsLack[i] != null && studentsLack[i].getName().equals(name)) { System.out.println(studentsLack[i]); return; } } System.out.println("没有查询到缺勤人信息"); } }
package com.test.dormitory; //菜单栏 public class meau { //登录菜单 public void LoginMeau(){ System.out.println("=======校园宿舍管理系统======="); System.out.println("\t\t1.登录"); System.out.println("\t\t2.注册"); System.out.println("\t\t3.退出"); } //功能菜单 public void FunctionMeau(){ System.out.println("=======宿舍管理员管理======="); System.out.println("\t\t1.宿舍管理员管理"); System.out.println("\t\t2.学生信息管理"); System.out.println("\t\t3.宿舍楼信息管理"); System.out.println("\t\t4.宿舍信息管理"); System.out.println("\t\t5.学生缺寝管理"); System.out.println("\t\t6.退出"); } //宿舍管理员管理菜单 public void AdministratorsMeau(){ System.out.println("=======宿舍管理员管理======="); System.out.println("\t\t1.添加管理员用户"); System.out.println("\t\t2.删除管理员用户信息"); System.out.println("\t\t3.查找管理员信息"); System.out.println("\t\t4.修改管理员信息"); System.out.println("\t\t5.退出"); } //学生信息管理菜单 public void StudentMeau(){ System.out.println("======宿舍学生信息管理======"); System.out.println("\t\t1.添加学生信息"); System.out.println("\t\t2.删除学生信息"); System.out.println("\t\t3.查找学生信息"); System.out.println("\t\t4.修改学生信息"); System.out.println("\t\t5.导出学生信息"); System.out.println("\t\t6.退出"); } //宿舍楼信息管理菜单 public void DormitoryBuildeMeau(){ System.out.println("======宿舍楼信息管理======"); System.out.println("\t\t1.添加宿舍楼信息"); System.out.println("\t\t2.删除宿舍楼信息"); System.out.println("\t\t3.查找宿舍楼信息"); System.out.println("\t\t4.修改宿舍楼信息"); System.out.println("\t\t5.导出宿舍楼信息"); System.out.println("\t\t6.退出"); } //宿舍信息管理菜单 public void DormitoryMeau(){ System.out.println("======宿舍信息管理======"); System.out.println("\t\t1.添加宿舍信息"); System.out.println("\t\t2.删除宿舍信息"); System.out.println("\t\t3.查找宿舍信息"); System.out.println("\t\t4.修改宿舍信息"); System.out.println("\t\t5.导出宿舍信息"); System.out.println("\t\t6.退出"); } public void AbsenteeismMeau(){ System.out.println("======学生缺寝管理======"); System.out.println("\t\t1.增加学生缺寝记录"); System.out.println("\t\t2.删除缺寝记录"); System.out.println("\t\t3.查询学生缺寝记录"); System.out.println("\t\t4.退出"); } }
package com.test.dormitory; import java.util.Objects; //学生缺寝管理:学生缺寝时,能够记录学生缺寝记录, // 如果缺寝信息有误,学生申诉后能够修改缺寝信息、删除缺寝信息、查询学生缺寝信息 public class StudentsLack { public String name; public String messages; public StudentsLack(String name, String messages) { this.name = name; this.messages = messages; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getMessages() { return messages; } public void setMessages(String messages) { this.messages = messages; } @Override public String toString() { return "学生缺寝记录{" + "姓名='" + name + '\'' + ", 缺勤记录='" + messages + '\'' + '}'; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; StudentsLack that = (StudentsLack) o; return Objects.equals(name, that.name); } }
package com.test.dormitory; import java.util.Objects; //学生信息管理:能够添加学生信息、删除学生信息、 // 查找学生信息、修改学生信息、导入学生信息、导出学生信息 public class StudentMessage { //姓名 public String name; //电话 public int number; //哪个寝室楼 public String position; //缺勤次数 public String lack; public StudentMessage(String name, int number, String position, String lack) { this.name = name; this.number = number; this.position = position; this.lack = lack; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getNumber() { return number; } public void setNumber(int number) { this.number = number; } public String getPosition() { return position; } public void setPosition(String position) { this.position = position; } public String getLack() { return lack; } public void setLack(String lack) { this.lack = lack; } @Override public String toString() { return "学生信息{" + "姓名='" + name + '\'' + ", 电话=" + number + ", 寝室号='" + position + '\'' + ", 缺勤次数=" + lack + '}'; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; StudentMessage that = (StudentMessage) o; return Objects.equals(name, that.name); } }
package com.test.dormitory; import java.util.Objects; //宿舍信息管理:能够添加宿舍信息、删除宿舍信息、 // 查找宿舍信息、修改宿舍信息、导入宿舍信息、导出宿舍信息. public class D_message { public String Id; public String PersonNumber; public String MainName; public D_message(String id, String personNumber, String mainName) { Id = id; PersonNumber = personNumber; MainName = mainName; } public String getId() { return Id; } public void setId(String id) { Id = id; } public String getPersonNumber() { return PersonNumber; } public void setPersonNumber(String personNumber) { PersonNumber = personNumber; } public String getMainName() { return MainName; } public void setMainName(String mainName) { MainName = mainName; } @Override public String toString() { return "寝室信息{" + "寝室号=" + Id + ", 寝室人数=" + PersonNumber + ", 寝室长='" + MainName + '\'' + '}'; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; D_message dMessage = (D_message) o; return Id == dMessage.Id; } }
package com.test.dormitory; import sun.plugin.javascript.navig4.Layer; import java.util.Objects; //宿舍楼信息管理:能够添加宿舍楼信息、删除宿舍楼信息、 // 查找宿舍楼信息、修改宿舍楼信息、导入宿舍楼信息、导出宿舍楼信息. public class D_B_message { public String Name; public String Responsible; public String RoomNumber; public D_B_message(String name,String responsible, String roomNumber) { Name = name; Responsible = responsible; RoomNumber = roomNumber; } public String getName() { return Name; } public void setName(String name) { Name = name; } public String getLayer() { return Responsible; } public void setLayer(String Responsible) { Responsible = Responsible; } public String getRoomNumber() { return RoomNumber; } public void setRoomNumber(String roomNumber) { RoomNumber = roomNumber; } @Override public String toString() { return "宿舍楼{" + "宿舍楼号='" + Name + '\'' + ", 负责人=" + Responsible + ", 房间数=" + RoomNumber + '}'; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; D_B_message dBMessage = (D_B_message) o; return Objects.equals(Name, dBMessage.Name); } }
package com.test.dormitory; import java.util.Objects; //宿舍管理员管理:能够添加管理员用户、删除管理员用户信息、 // 查找管理员信息修改管理员信息。 public class administrators { //名字 public String name; //Id public String ID; //电话 public int PhoneNumber; //负责位置 public String position; public administrators(String name,String ID, int phoneNumber, String position) { this.name = name; this.ID = ID; PhoneNumber = phoneNumber; this.position = position; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getID() { return ID; } public void setID(String ID) { this.ID = ID; } public int getPhoneNumber() { return PhoneNumber; } public void setPhoneNumber(int phoneNumber) { PhoneNumber = phoneNumber; } public String getPosition() { return position; } public void setPosition(String position) { this.position = position; } @Override public String toString() { return "宿舍管理员{" + "姓名='" + name + '\'' + ", 工号=" + ID + ", 电话=" + PhoneNumber + ", 负责宿舍楼='" + position + '\'' + '}'; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; administrators that = (administrators) o; return Objects.equals(name, that.name); } }
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/116004.html