停車場管理系統(tǒng)(java)_第1頁
停車場管理系統(tǒng)(java)_第2頁
停車場管理系統(tǒng)(java)_第3頁
停車場管理系統(tǒng)(java)_第4頁
停車場管理系統(tǒng)(java)_第5頁
免費預(yù)覽已結(jié)束,剩余11頁可下載查看

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、停車場管理系統(tǒng)(java)import java io *;public class Method(private int intinput() throws IOException f NumberFormatException<BufferedReader br=new BufferedReader(newInputstreamReader(System in);String str=br readLine();int i=Hnt;eger .pairseZnt; (str);return i;private String stringinput() throws IOExcepti

2、on<BufferedReader br=new BufferedReader(newInputstreamReader(System in);String str=br readLine();return str;private boolean between(int n z int min r int max)for(int i=min;i<=max;i+)if (n=i)return true;return false;private void printerror()System, out .printin入錯誤!請重新輸入! n);String sip()String s

3、tr;while(true)trystr=this stringinput();catch(IOException e)this printerror(); continue;break;return str;int iip (int minf int max)int n=0;while(true)tryn=this intinput();catch(IOException e)this print;ei?i?or (); continue;catch (NiunberFormatException e) (this .printerroi?(); continue;if(!this betw

4、een(n,min,max)this .printerror* (); continue;break;return n;public class CarS tring car_no ;String state;Car ()car_no=null;state=null;public class Stop(Car data;int size;Stop ()data=new Car1;size=O;private Car peek()return datasize-1;private boolean isFull()<return size=data length;private Car po

5、p()size;return datasize;void pop(int location z Passway p z Temp t)<if(location=this size)(System.out:.printin (this peek() car_no+”號車離開停車場”); this pop();elseint f=this size;for(int i=l;i<=f-location;i+)t push(this peek();this pop();Sys tem .out;, printin (this peek() car_no+” 號車離開停車場”); this

6、pop();for(int i=0;!t isEmpty() ;i+)this push(t peek();t pop ();if(!p isEmp七y()(this push(p datap front);p remove();void push(Car target)<if (this isFullO )stretch ();datasize=target;size+;target state=target car_no+”號車位于停車場”+siNe+"號位”; System, out println (target car*_no+”號車逬入停車場號位");bo

7、olean isln(String s)if (size=O)return false;for (int i=0 ; Ksize; i+)if(datai car no equals(s)return true;return false;private void stretch()<Car newData=new Cardata length*2;for(int i=0;iVdata length;i+)newDatai=datai;data=newData;void print()for(int i=0;i<size;i+)System .out;, printin (data

8、i state 仁 oString ();public class Passway(Car data;int size;int front;Passway()data=new Car1;size=O;front=0;boolean isEmpty()return size=O;private boolean isFull()<return size=data length;public Car remove()Car result=datafront;front=()%data longth;size;Passway t=new Passway();for (int i=0 ; Kthi

9、s size; i+)t add(this datafront+i);return resuIt;void add(Car target)if (this isFullO )this stretch();data(front+size)%data length=target;size+;target state=target car_no+”號車位于便道”+siNe+"號位”; System, out println (target car*_no+”號車逬入便道H+size+H號位”);boolean isln(String s)if (size=O)return false;fo

10、r(int i=0;i<size;i+)if(this data(front+i)%data length car_no equals(s) return true;return false;private void stretch()Car newData=new Cardata.length*2;for(int i=0;i<data length;i+)newDatai=data(front+i)%data length;data=newData;front=0;void print()for (int i=0 ; Ksize; i+)System out; .println

11、(data (front+i) %data length state toString ();public class Temp(private Car data;private int size;Temp()data=new Car1;size=O;boolean isEmpty()Carreturn size=O;peek()return datasize-1;private boolean isFull()return size=data length;Car pop()<size;return datasize;void push(Car target)<if(this i

12、sFull()stretch ();datasize=target;size+;System, out .printin (target. uar_no+"號車暫時離開停車場"); target. state=target. carno+H號車暫時離開停車場"private void stretch()Car newData=new Cardata length*2; for(int i=0;i<data length;i+)newDatai=datai;da ta=newD a ta;public class cmspublic static void m

13、ain(String args)Stop stop=new Stop();Passway passway=new Passway();Temp temp=new Temp();Method method=new Method();System. out. printin (n歡迎使用停車場管理系統(tǒng)!"); while(true)System out;System out;System out;System out;System out;System out;int select=methodiip(1,5);switch(select) case 1:int i;Stop newst

14、op=new Stop();Passway newpassway=new Passway();stop=newstop;passway=newpassway;for(i=l;i<=5;i+)System, out. printin (n請輸入停車位n+i+n號車位汽車的編號,鍵入$完結(jié)”);String str=null; while(true)USHU f 喘4)xq( = s = )旳TReo 口4切)3-Hf4)nuT4uoo二 XI 刪一fMijBwflJ出蘭LUT4UTd4noUIU4AS(MAtn) SHWH ARMStnRd) 3-Hf unuTAUOO<爍起刪*&#

15、174;Mw出ewflj出蘭Lunu-dHd4noUI£ 切 ns) (H4(O)UI5T do4(n)3T f () d-H(nPOI4a)UI=x4(nKUnu-H3uoo二二 Y sffBEw®出e灼 2 出豈乙 UT4u-HHd3noUIU4SAS(I0H4 切)UIcnT Q O4s)3-dK()d-Hcopor4UUI=rH0H4co?nH4) ut-hvm mwoxa切 6UTH4S二血保s<sDIP嫖s卅虹卻Din匸 +U+=迪B<滋B=) UTAUTHd十(+U:IHU 4U-H)HO3(SHH2N-H切 do4 旳)3-H亠(f (o) &#

16、163;(nn d d 04(0MPWHOfl oos() XRO M2UMO XROif(passway isHn(strOl)System, out .printin已在便道里'請重新輸入!continue;break;if(strOl equals(H$")break;elseCar c=new Car();c car_no=s tr01;passwayadd(c);continue;case2 : System, out.printin (H請輸入待逬汽車的編號:想);String str02=null;while(true)str02=methodsip();if(

17、stop isTn(str02)(Sys tem .out. printin (H已在停車場里,請重新輸入! ”);continue;if(passway isTn(str02)Sys tem .out. printin (H已在便道里/請重新輸入! ”);continue;break;Car c=new Car();if(stop size<5)stop push(c);elsepasswayadd(c);continue;case 3 : System, out .printin (n請輸入待出汽車的停車位編號:H);int 12;i2=method iip(1,5);if(i2&g

18、t;stop size)System, out.printin (n此車位尚無汽車! ”);continue;stop pop(i2, passway, temp);continue;case 4 : System, out .printin (n請選擇查詢區(qū)域:n);Sys tem ou t println (” 1:停車場 H;System out println ("2 :便道n);System out;.println ("3 :扌丁印全咅;int i4=methodiip(1,3);if(i4=l)System, out .printin (H請輸入待查詢停車場車位編號:”);int i41=me仁hodiip(1,5);if(stop size<i41)Sys tem. ou t. printin (n 此車位尚無汽車! ”);elseSyste m out; printl n(sto p.dat a 141-1 .state. toString ();elseif (i4=2)System, out. printin (入待查詢便道車位編號:”

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論