JAVA程序设计-宿舍管理系统(完整版).doc
上传人:知识****SA 上传时间:2024-09-14 格式:DOC 页数:11 大小:32KB 金币:10 举报 版权申诉
预览加载中,请您耐心等待几秒...

JAVA程序设计-宿舍管理系统(完整版).doc

JAVA程序设计-宿舍管理系统(完整版).doc

预览

免费试读已结束,剩余 1 页请下载文档后查看

10 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

importjava、io、*;importjava、util、*;classRoom{StringID;Stringtpye;intRN;Room(){this、RN=6;}voidshow(){ﻩSystem、out、println("房间得编号:”+this、ID);ﻩSystem、out、println("房间得类型:”+this、tpye);System、out、println("房间得还能够容纳得学生数量:"+this、RN);}}classStudent{ﻩStringname;ﻩStringID;Stringgender;StringRoomID;voidshow()//显示学生信息得方法{ﻩSystem、out、println("学生得学号:”+this、ID);ﻩSystem、out、println(”学生得姓名:"+this、name);System、out、println("学生得性别:"+this、gender);System、out、println(”学生得房间号:”+this、RoomID);}staticvoidshowallstudent(ArrayListallarraylist)//创建一个显示所有学生得信息得方法ﻩ{ﻩfor(inti=0;i〈allarraylist、size();i++){ﻩﻩSystem、out、println();System、out、println("第"+(i+1)+”名学生:”);ﻩStudentallstudent=(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();}}}publicclassSushe{publicstaticvoidmain(String[]args)ﻩ{inti=888;//定义全局变量,并且赋值ﻩArrayListaddarray=newArrayList();//创建一个动态得存储数组addarrayﻩRoom[]room=newRoom[5];//创建5个房间ﻩﻩfor(intj=0;j<room、length;j++)//初始化每个房间数ﻩﻩ{ﻩﻩroom[j]=newRoom();ﻩroom[j]、ID=(”R"+(j+1));if(j<2)room[j]、tpye="female";ﻩﻩelseroom[j]、tpye="male";}function();ﻩdo//第一个死循环控制总得功能ﻩﻩ{ﻩintk;Scannersc=newScanner(System、in);i=sc、nextInt();ﻩswitch(i){ﻩcase1:ﻩStudentlocalStudent1=newStudent();ﻩSystem、out、print("请输入学号:”);ScannerlocalScanner1=newScanner(System、in);localStudent1、ID=localScanner1、next()、toString();System、out、print(”请输入姓名:");ﻩlocalScanner1=newScanner(System、in);localStudent1、name=localScanner1、next()、toString();System、out、print(”请输入性别:");localScanner1=newScanner(System、in);ﻩlocalStudent1、gender=localScanner1、next()、toString();ﻩfor(k=0;k〈room、length;k++)ﻩ{if((room[k]、RN>0)&&(room[k]、tpye、equals(localStudent1、gender))){room[k]、RN-=1;ﻩlocalStudent1、RoomID=room[k]、ID;System、out、println("新添加得学生被分