JAVA程序设计 宿舍管理系统(完整版)
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
System.out.println("*");
System.out.println("*\t[2] 查看宿舍信息");
System.out.println("*");
System.out.println("*\t[3] 按房间号查看房间信息");
Student localStudent3 = (Student)addarray.get(i2); String m = localStudent3.gender; String m1 = localStudent3.RoomID ; if (localStudent3.ID.equals(str5)) {
Student localStudent3 = (Student)addarray.get(i1); if (localStudent3.ID.equals(str3)) {
System.out.print("学号为" + localStudent3.ID + "的学生已被删除!"); addarray.remove(i1); break; } } function(); breakFra Baidu bibliotek case 8: showfunction(); break; case 0: System.out.println("\t\t 谢谢使用!\n\t\t(*^__^*)\n\t\t 再见!"); break; default: System.out.println("你按的神马东西,没看说明吗?\t\t-_-#"); function(); } }while(i!=0); } static void function()
for (int n = 0; n < addarray.size(); n++) {
Student localStudent2 = (Student)addarray.get(n); if (localStudent2.ID.equals(str2)) {
localStudent2.show(); break; } } function(); break; case 6: System.out.print("请输入待修改学生的学号:"); Scanner localScanner5 = new Scanner(System.in); String str5 = localScanner5.next().toString(); for (int i2 = 0; i2 < addarray.size(); i2++) {
localStudent3.RoomID = room[k].ID; System.out.println("修改的学生被分配到房间:" + room[k].ID); addarray.add(localStudent3); break;
} } } System.out.println("恭喜你!修改成功!"); function(); }
class Student { String name; String ID; String gender; String RoomID; void show()//显示学生信息的方法 { System.out.println("学生的学号:" + this.ID); System.out.println("学生的姓名:" + this.name); System.out.println("学生的性别:" + this.gender); System.out.println("学生的房间号:" + this.RoomID); } static void showallstudent(ArrayList allarraylist)//创建一个显示所有学生的信息的方法 { for(int i = 0; i<allarraylist.size();i++) { System.out.println(); System.out.println("第" + (i + 1) + "名学生:"); Student allstudent = (Student)allarraylist.get(i); System.out.println("学生的学号:" + allstudent.ID); System.out.println("学生的姓名:" + allstudent.name); System.out.println("学生的性别:" + allstudent.gender); System.out.println("学生的房间号:" + allstudent.RoomID); System.out.println(); }
}
break; case 7:
System.out.print("请输入待删除学生的学号:"); Scanner localScanner4 = new Scanner(System.in); String str3 = localScanner4.next().toString();
for (int i1 = 0; i1 < addarray.size(); i1++) {
}
}
public class Sushe { public static void main(String[] args) { int i = 888;//定义全局变量,并且赋值 ArrayList addarray = new ArrayList();//创建一个动态的存储数组 addarray Room[] room = new Room[5];//创建 5 个房间 for(int j=0;j<room.length;j++)//初始化每个房间数 { room[j] = new Room(); room[j].ID = ("R"+(j+1)); if(j<2)room[j].tpye = "female"; else room[j].tpye = "male"; } function(); do//第一个死循环控制总的功能 { int k; Scanner sc = new Scanner(System.in); i = sc.nextInt(); switch (i) { case 1: Student localStudent1 = new Student();
System.out.print("请输入请输入修改后的学生的性别:"); localScanner11 = new Scanner(System.in); localStudent3.gender = localScanner11.next().toString(); if (!(m.equals(localStudent3.gender))){
System.out.print("请输入性别:"); localScanner1 = new Scanner(System.in); localStudent1.gender = localScanner1.next().toString();
for (k = 0; k < room.length; k++) {
room[m].show(); break; } } function(); break; case 4: Student.showallstudent(addarray); function(); break; case 5: System.out.print("请输入待查询学生的学号:"); Scanner localScanner3 = new Scanner(System.in); String str2 = localScanner3.next().toString();
for(k = 0; k< room.length ;k++) {
if(room[k].ID.equals(m1)){room[k].RN++;break;} } addarray.remove(i2); for (k = 0; k < room.length; k++) { if ((room[k].RN > 0) && (room[k].tpye.equals(localStudent3.gender))) { room[k].RN -= 1;
if ((room[k].RN > 0) && (room[k].tpye.equals(localStudent1.gender))) {
room[k].RN -= 1; localStudent1.RoomID = room[k].ID; System.out.println("新添加的学生被分配到房间:" + room[k].ID); break; } }
System.out.print("请输入学号:"); Scanner localScanner1 = new Scanner(System.in); localStudent1.ID = localScanner1.next().toString();
System.out.print("请输入姓名:"); localScanner1 = new Scanner(System.in); localStudent1.name = localScanner1.next().toString();
System.out.print("请输入修改后的学生的学号:"); Scanner localScanner11 = new Scanner(System.in); localStudent3.ID = localScanner11.next().toString();
System.out.print("请输入请输入修改后的学生的姓名:"); localScanner11 = new Scanner(System.in); localStudent3.name = localScanner11.next().toString();
addarray.add(localStudent1); function(); break; case 2: System.out.println("所有房间信息如下:"); for (k = 0; k < room.length; k++) {
System.out.println("房间号:" + room[k].ID); System.out.println("房间类型:" + room[k].tpye); System.out.println("房间还能容纳的学生数:" + room[k].RN); System.out.println(); } function(); break; case 3: System.out.print("请输入待查询房间的房间号:"); Scanner localScanner2 = new Scanner(System.in); String str1 = localScanner2.next().toString(); for (int m = 0; m < room.length; m++) { if (room[m].ID.equals(str1)) {
{
System.out.println("***************************************");
System.out.println("*\t\t 宿舍管理系统");
System.out.println("*");
System.out.println("*\t[1] 新增学生、并分配宿舍");
import java.io.*; import java.util.*; class Room {
String ID; String tpye; int RN; Room() {
this.RN = 6; } void show() {
System.out.println("房间的编号:"+this.ID); System.out.println("房间的类型:"+this.tpye); System.out.println("房间的还能够容纳的学生数量:"+this.RN); } }