




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、import java.io.*;import java.util.*;class Room String ID;String tpye;int RN;Room()this.RN = 6;void show()System.out.println(" 房間的編號(hào):"+this.ID);System.out.println(" 房間的類型:"+this.tpye);System.out.println(" 房間的還能夠容納的學(xué)生數(shù)量:"+this.RN); class Student String name;String ID;Stri
2、ng gender;String RoomID;void show()/ 顯示學(xué)生信息的方法System.out.println(" 學(xué)生的學(xué)號(hào):" +this.ID);System.out.println(" 學(xué)生的姓名:" +);System.out.println(" 學(xué)生的性別:" +this.gender);System.out.println(" 學(xué)生的房間號(hào): " + this.RoomID); static void showallstudent(ArrayList allarra
3、ylist)/ 創(chuàng)建一個(gè)顯示所有學(xué)生的信息的方法for(int i = 0; i<allarraylist.size();i+)System.out.println();System.out.println(" 第" + (i + 1) + " 名學(xué)生: ");Student allstudent = (Student)allarraylist.get(i);System.out.println(" 學(xué)生的學(xué)號(hào):" +allstudent.ID);System.out.println(" 學(xué)生的姓名:" +a
4、);System.out.println(" 學(xué)生的性別:" +allstudent.gender);System.out.println(" 學(xué)生的房間號(hào): " + allstudent.RoomID);System.out.println();public class Sushe public static void main(String args) int i = 888;/ 定義全局變量,并且賦值A(chǔ)rrayList addarray = new ArrayList();/ 創(chuàng)建一個(gè)動(dòng)態(tài)的存儲(chǔ)數(shù)組 addarray R
5、oom room = new Room5;/ 創(chuàng)建 5 個(gè)房間 for(int j=0;j<room.length;j+)/ 初始化每個(gè)房間數(shù) roomj = new Room();roomj.ID = ("R"+(j+1);if(j<2)roomj.tpye = "female"else roomj.tpye = "male" function();do第一個(gè)死循環(huán)控制總的功能 int k;Scanner sc = new Scanner(System.in);i = sc.nextInt();switch (i) ca
6、se 1:Student localStudent1 = new Student();System.out.print(" 請(qǐng)輸入學(xué)號(hào): ");Scanner localScanner1 = new Scanner(System.in);localStudent1.ID = localScanner1.next().toString();System.out.print(" 請(qǐng)輸入姓名: ");localScanner1 = new Scanner(System.in);localS = localScanner1.next().
7、toString();System.out.print(" 請(qǐng)輸入性別: ");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(" 新添加的學(xué)生被分配到房間: " + roomk.ID); break; addarray.add(localStudent1);function();break;case 2:System.out.println(" 所有房間信息如下: ");for (k = 0; k < room.length; k+)System.out.println(" 房間號(hào): " + roomk.ID);System.out.println(" 房間類型: " + roomk.tpye);
9、System.out.println(" 房間還能容納的學(xué)生數(shù): " + roomk.RN);System.out.println();function();break;case 3:System.out.print(" 請(qǐng)輸入待查詢房間的房間號(hào): ");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(" 請(qǐng)輸入待查詢學(xué)生的學(xué)號(hào): ");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(" 請(qǐng)輸入待修改學(xué)生的學(xué)號(hào): ");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(" 請(qǐng)輸入修改后的學(xué)生的學(xué)號(hào): ");Scanner localScanner11 = new Scanner(System.in); localStudent3.ID = localScanner11.next().toString
13、();System.out.print(" 請(qǐng)輸入請(qǐng)輸入修改后的學(xué)生的姓名: "); localScanner11 = new Scanner(System.in);localS = localScanner11.next().toString();System.out.print(" 請(qǐng)輸入請(qǐng)輸入修改后的學(xué)生的性別: "); 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、學(xué)生被分配到房間: " + roomk.ID);addarray.add(localStudent3);break;System.out.println(" 恭喜你!修改成功! ");function();break;case 7:System.out.print(" 請(qǐng)輸入待刪除學(xué)生的學(xué)號(hào): ");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(" 學(xué)號(hào)為 " + localStudent3.ID + " 的學(xué)生已被刪除! ");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宿舍管理系統(tǒng)");新增學(xué)生、并分配宿舍");查看宿舍信息 ");按房間號(hào)查看房間信息 ");查看所有學(xué)生信息 ");按學(xué)生學(xué)號(hào)查詢學(xué)生信息 ");按學(xué)號(hào)修改學(xué)生信息 ");刪除指定學(xué)生");! !詳細(xì)使用說明信息! ! ! &
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作者:李月超班級(jí):樂山師范學(xué)院");");");計(jì)科學(xué)院 _12 級(jí)網(wǎng)絡(luò)工程班");");開發(fā)日期: 2013 年 12 月 ");System.out.println("*");System.out.println("*課程題目:n*設(shè)計(jì)宿舍管理系統(tǒng)n*宿舍管理要求:n*可以新增 學(xué)生,新增學(xué)生的同時(shí),按以上要求由系統(tǒng)自動(dòng)將學(xué)生安排進(jìn)房間n*可以列出所有房間信息n*可以通過房間號(hào)查看房間信息,以及該房間內(nèi)住宿學(xué)生的信
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 超疏水表面的耐久性研究進(jìn)展及其應(yīng)用領(lǐng)域探討
- 農(nóng)業(yè)面源污染控制-第5篇-洞察及研究
- 機(jī)房參觀管理辦法細(xì)則
- 農(nóng)戶生計(jì)決策管理辦法
- 工業(yè)自動(dòng)化系統(tǒng)設(shè)計(jì)優(yōu)化研究
- 華為應(yīng)用限制管理辦法
- 協(xié)會(huì)業(yè)余球員管理辦法
- 生產(chǎn)經(jīng)營(yíng)單位安全主體責(zé)任規(guī)定
- 導(dǎo)電水凝膠對(duì)神經(jīng)肌肉組織修復(fù)的研究進(jìn)展
- 內(nèi)部職務(wù)異動(dòng)管理辦法
- 東北大學(xué)分析化學(xué)期末試卷
- 老年健康照護(hù)課件
- 2024屆河北省唐山市玉田縣物理高一第二學(xué)期期末質(zhì)量檢測(cè)試題含解析
- 第三方醫(yī)療消毒供應(yīng)中心項(xiàng)目可行性研究報(bào)告
- 貨架安裝施工方案
- 異口同音公開課
- 專利代理人資格考試實(shí)務(wù)試題及參考答案
- 運(yùn)用信息技術(shù)助力勞動(dòng)教育創(chuàng)新發(fā)展 論文
- GB/T 602-2002化學(xué)試劑雜質(zhì)測(cè)定用標(biāo)準(zhǔn)溶液的制備
- GB/T 4074.8-2009繞組線試驗(yàn)方法第8部分:測(cè)定漆包繞組線溫度指數(shù)的試驗(yàn)方法快速法
- 2023年涉縣水庫(kù)投資管理運(yùn)營(yíng)有限公司招聘筆試模擬試題及答案解析
評(píng)論
0/150
提交評(píng)論