JAVA程序设计-宿舍管理系统(完整版)0001_第1页
JAVA程序设计-宿舍管理系统(完整版)0001_第2页
JAVA程序设计-宿舍管理系统(完整版)0001_第3页
JAVA程序设计-宿舍管理系统(完整版)0001_第4页
JAVA程序设计-宿舍管理系统(完整版)0001_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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); class Student String name;String ID;Stri

2、ng gender;String RoomID;void show()/ 显示学生信息的方法System.out.println(" 学生的学号:" +this.ID);System.out.println(" 学生的姓名:" +);System.out.println(" 学生的性别:" +this.gender);System.out.println(" 学生的房间号: " + this.RoomID); static void showallstudent(ArrayList allarra

3、ylist)/ 创建一个显示所有学生的信息的方法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(" 学生的姓名:" +a

4、);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();/ 创建一个动态的存储数组 addarray R

5、oom 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) ca

6、se 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);localS = localScanner1.next().

7、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;S

8、ystem.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);

9、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(

10、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 local

11、Student2 = (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();

12、 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

13、();System.out.print(" 请输入请输入修改后的学生的姓名: "); localScanner11 = new Scanner(System.in);localS = localScanner11.next().toString();System.out.print(" 请输入请输入修改后的学生的性别: "); localScanner11 = new Scanner(System.in);localStudent3.gender = localScanner11.next().toString();if (!(m

14、.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(" 修改的

15、学生被分配到房间: " + 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 < addarr

16、ay.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(*A_A*)n

17、tt再见!");break;default:System.out.println(" 你按的神马东西,没看说明吗? tt-_-#");function();while(i!=0);static void function()System.out.println("*");System.out.println("*ttSystem.out.println("*");System.out.println("*t1System.out.println("*");System.out.prin

18、tln("*t2System.out.println("*");System.out.println("*t3System.out.println("*");System.out.println("*t4System.out.println("*");System.out.println("*t5System.out.println("*");System.out.println("*t6System.out.println("*");Syste

19、m.out.println("*t7System.out.println("*");System.out.println("*t8System.out.println("*");System.out.println("*t0宿舍管理系统");新增学生、并分配宿舍");查看宿舍信息 ");按房间号查看房间信息 ");查看所有学生信息 ");按学生学号查询学生信息 ");按学号修改学生信息 ");删除指定学生");! !详细使用说明信息! ! ! &

20、quot;);退出 ");System.out.println("*"System.out.println("Please select a funtion:");static void showfunction() System.out.println("*");System.out.println("|ttJA VA);序");System.out.println("|ttSystem.out.println("|ttSystem.out.println("|ttSyst

21、em.out.println("|ttSystem.out.println("|ttSystem.out.println("|tt作者:李月超班级:乐山师范学院");");");计科学院 _12 级网络工程班");");开发日期: 2013 年 12 月 ");System.out.println("*");System.out.println("*课程题目:n*设计宿舍管理系统n*宿舍管理要求:n*可以新增 学生,新增学生的同时,按以上要求由系统自动将学生安排进房间n*可以列出所有房间信息n*可以通过房间号查看房间信息,以及该房间内住宿学生的信

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论