JAVA程序设计-宿舍管理系统(完整版)(10页).doc
《JAVA程序设计-宿舍管理系统(完整版)(10页).doc》由会员分享,可在线阅读,更多相关《JAVA程序设计-宿舍管理系统(完整版)(10页).doc(10页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、-JAVA程序设计-宿舍管理系统(完整版)-第 10 页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 g
2、ender;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; iallarraylist.
3、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(学生的房间号: + allstuden
4、t.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;jroom.length;j+)/初始化每个房间数roomj = new Room();roomj.ID = (R+(j+1);if(j2)roomj.tpye = female;e
5、lse 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.o
6、ut.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 0) & (roomk.tpye.equals(localStudent1.gender) roomk.
7、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
8、.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; functio
9、n(); 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
10、(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.ge
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JAVA 程序设计 宿舍 管理 系统 完整版 10
限制150内