下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、停车场管理系统(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欢迎使用停车场管理系统!"); 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号车位汽车的編号,键入$完结”);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请选择查询区域: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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年《教育知识与能力》真题解析及下载
- 智能城市建设项目管理方案
- 2025年艺考速写试卷真题及答案
- 电子制造业供应链协同平台建设及调研
- 乡镇餐饮连锁品牌本地食材合作调研
- 乡镇智慧农业AI生态种植调研
- 2026年家政服务培训销售招聘策略调研
- 2026年宁夏小学特岗真题及答案
- 法语语法基础知识点总结
- 电商直播销售技巧与实操经验总结
- 国家开放大学《刑事诉讼法学》形考任务2答案
- 乡镇避孕药具培训资料
- 采购激光打标机合同范本
- 履带吊课件教学课件
- 元旦联欢会:疯狂动物城
- 军事地图使用课件
- 医院法律法规专项培训实施计划方案
- 创伤护理新进展与展望
- 反渗透膜性能检测与维护流程
- 肝功能不全2型糖尿病患者的降糖药物选择方案
- 2025年专升本行政管理公文写作测试(含答案)
评论
0/150
提交评论