JAVA程序设计-宿舍管理系统(完整版)(25页).doc
-
资源ID:34800232
资源大小:37KB
全文页数:25页
- 资源格式: DOC
下载积分:15金币
快捷下载
会员登录下载
微信登录下载
三方登录下载:
微信扫一扫登录
友情提示
2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
|
JAVA程序设计-宿舍管理系统(完整版)(25页).doc
-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); 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();public class Sushe public static void main(String args)int i = 888;/定义全局变量,并且赋值ArrayList addarray = new ArrayList();/创建一个动态的存储数组addarrayRoom room = new Room5;/创建5个房间for(int j=0;j<room.length;j+)/初始化每个房间数roomj = new Room();roomj.ID = ("R"+(j+1);if(j<2)roomj.tpye = "female"else roomj.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("请输入学号:"); 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("请输入性别:"); localScanner1 = new Scanner(System.in); localStudent1.gender = localScanner1.next().toString(); for (k = 0; k < room.length; k+) if (roomk.RN > 0) && (roomk.tpye.equals(localStudent1.gender) roomk.RN -= 1; localStudent1.RoomID = roomk.ID; System.out.println("新添加的学生被分配到房间:" + roomk.ID); break; addarray.add(localStudent1); function(); break; case 2: System.out.println("所有房间信息如下:"); for (k = 0; k < room.length; k+) System.out.println("房间号:" + roomk.ID); System.out.println("房间类型:" + roomk.tpye); System.out.println("房间还能容纳的学生数:" + roomk.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 (roomm.ID.equals(str1) roomm.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 (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+) Student localStudent3 = (Student)addarray.get(i2); String m = localStudent3.gender; String m1 = localStudent3.RoomID ; if (localStudent3.ID.equals(str5) 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(); System.out.print("请输入请输入修改后的学生的性别:"); localScanner11 = new Scanner(System.in); localStudent3.gender = localScanner11.next().toString(); if (!(m.equals(localStudent3.gender) for(k = 0; k< room.length ;k+) if(roomk.ID.equals(m1)roomk.RN+;break; addarray.remove(i2); for (k = 0; k < room.length; k+) if (roomk.RN > 0) && (roomk.tpye.equals(localStudent3.gender) roomk.RN -= 1; localStudent3.RoomID = roomk.ID; System.out.println("修改的学生被分配到房间:" + roomk.ID); addarray.add(localStudent3); break; System.out.println("恭喜你!修改成功!"); function(); 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+) Student localStudent3 = (Student)addarray.get(i1); if (localStudent3.ID.equals(str3) System.out.print("学号为" + localStudent3.ID + "的学生已被删除!"); addarray.remove(i1); break; function(); break; case 8: showfunction(); break; case 0: System.out.println("tt谢谢使用!ntt(*_*)ntt再见!"); break; default: System.out.println("你按的神马东西,没看说明吗?tt-_-#"); function(); while(i!=0);static void function() System.out.println("*"); System.out.println("*tt宿舍管理系统"); System.out.println("*"); System.out.println("*t1 新增学生、并分配宿舍"); System.out.println("*"); System.out.println("*t2 查看宿舍信息"); System.out.println("*"); System.out.println("*t3 按房间号查看房间信息"); System.out.println("*"); System.out.println("*t4 查看所有学生信息"); System.out.println("*"); System.out.println("*t5 按学生学号查询学生信息"); System.out.println("*"); System.out.println("*t6 按学号修改学生信息"); System.out.println("*"); System.out.println("*t7 删除指定学生"); System.out.println("*"); System.out.println("*t8 !详细使用说明信息!"); System.out.println("*"); System.out.println("*t0 退出");System.out.println("*"); System.out.println("Please select a funtion:");static void showfunction() System.out.println("*"); System.out.println("|ttJAVA程序设计 "); System.out.println("|tt "); System.out.println("|tt作者:李月超 "); System.out.println("|tt "); System.out.println("|tt班级:乐山师范学院_计科学院_12级网络工程班"); System.out.println("|tt "); System.out.println("|tt开发日期:2013年12月");System.out.println("*");System.out.println("*课程题目:n*设计宿舍管理系统n*宿舍管理要求:n*可以新增学生,新增学生的同时,按以上要求由系统自动将学生安排进房间n*可以列出所有房间信息n*可以通过房间号查看房间信息,以及该房间内住宿学生的信息n*可以列出所有学生信息n*可以通过学生学号查看学生的信息n*可以删除指定学生");System.out.println("*tt提示:n*此程序的功能只能是0-9数字输入n*性别只能是female或者是male!");System.out.println("-");System.out.println("|tt宿舍管理系统"); System.out.println("|t1 新增学生、并分配宿舍"); System.out.println("|t2 查看宿舍信息"); System.out.println("|t3 按房间号查看房间信息"); System.out.println("|t4 查看所有学生信息"); System.out.println("|t5 按学生学号查询学生信息"); System.out.println("|t6 按学号修改学生信息"); System.out.println("|t7 删除指定学生"); System.out.println("|t8 !详细使用说明信息!"); System.out.println("|t0 退出");System.out.println("-"); System.out.println("Please select a funtion:");第 25 页-