




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、import java.io.*;public class methodprivate int intinput() throws ioexception,numberformatexceptionbufferedreader br=new bufferedreader(new inputstreamreader(system.in);string str=br.readline();int i=integer.parseint(str);return i;private string stringinput() throws ioexceptionbufferedreader br=new
2、bufferedreader(new inputstreamreader(system.in);string str=br.readline();return str;private boolean between(int n,int min,int max)for(int i=min;i=max;i+)if(n=i)return true;return false;private void printerror()system.out.println(输入错误!请重新输入!);string sip()string str;while(true)trystr=this.stringinput(
3、);catch(ioexception e)this.printerror();continue;break;return str;int iip(int min,int max)int n=0;while(true)tryn=input();catch(ioexception e) this.printerror(); continue; catch(numberformatexception e) this.printerror(); continue; if(!this.between(n,min,max) this.printerror(); continue; bre
4、ak;return n;public class car string car_no;string state;car()car_no=null;state=null;public class stop car data;int size;stop()data=new car1;size=0;private car peek()return datasize-1;private boolean isfull()return size=data.length;private car pop()size-;return datasize;void pop(int location,passway
5、p,temp t) if(location=this.size)system.out.println(this.peek().car_no+号车离开停车场);this.pop();elseint f=this.size;for(int i=1;i=f-location;i+)t.push(this.peek();this.pop();system.out.println(this.peek().car_no+号车离开停车场);this.pop();for(int i=0;!t.isempty();i+)this.push(t.peek();t.pop();if(!p.isempty() thi
6、s.push(p.datap.front);p.remove();void push(car target)if(this.isfull()stretch();datasize=target;size+;target.state=target.car_no+号车位于停车场+size+号位;system.out.println(target.car_no+号车进入停车场+size+号位);boolean isin(string s)if(size=0)return false;for(int i=0;isize;i+)if(datai.car_no.equals(s)return true;re
7、turn false;private void stretch()car newdata=new cardata.length*2;for(int i=0;idata.length;i+)newdatai=datai;data=newdata;void print()for(int i=0;isize;i+)system.out.println(datai.state.tostring();public class passway car data;int size;int front;passway()data=new car1;size=0;front=0;boolean isempty(
8、)return size=0;private boolean isfull()return size=data.length;public car remove()car result=datafront;front=(front+1)%data.length;size-;passway t=new passway(); for(int i=0;ithis.size;i+)t.add(this.datafront+i);return result;void add(car target)if(this.isfull()this.stretch();data(front+size)%data.l
9、ength=target;size+;target.state=target.car_no+号车位于便道+size+号位;system.out.println(target.car_no+号车进入便道+size+号位);boolean isin(string s) if(size=0)return false;for(int i=0;isize;i+)if(this.data(front+i)%data.length.car_no.equals(s)return true;return false;private void stretch()car newdata=new cardata.le
10、ngth*2;for(int i=0;idata.length;i+)newdatai=data(front+i)%data.length;data=newdata;front=0;void print()for(int i=0;isize;i+)system.out.println(data(front+i)%data.length.state.tostring();public class temp private car data;private int size;temp()data=new car1;size=0;boolean isempty()return size=0;car
11、peek()return datasize-1;private boolean isfull()return size=data.length;car pop()size-;return datasize;void push(car target)if(this.isfull()stretch();datasize=target;size+;system.out.println(target.car_no+号车暂时离开停车场);target.state=target.car_no+号车暂时离开停车场;private void stretch()car newdata=new cardata.l
12、ength*2;for(int i=0;idata.length;i+)newdatai=datai;data=newdata;public class cmspublic static void main(string args)stop stop=new stop();passway passway=new passway();temp temp=new temp();method method=new method();system.out.println(欢迎使用停车场管理系统!);while(true)system.out.println(请选择操作);system.out.prin
13、tln(1: 初始化);system.out.println(2:进车);system.out.println(3:出车);system.out.println(4:查询);system.out.println(5:退出);int select=method.iip(1,5);switch(select)case 1:int i; stop newstop=new stop(); passway newpassway=new passway(); stop=newstop; passway=newpassway; for(i=1;i=5;i+) system.out.println(请输入停车
14、位+i+号车位汽车的编号,键入$完结); string str=null; while(true) str=method.sip(); if(stop.isin(str) system.out.println(此车已在停车场里,请重新输入!); continue; if(passway.isin(str) system.out.println(此车已在便道里,请重新输入!); continue; break; if(str.equals($) break; else car c=new car(); c.car_no=str; stop.push(c); if(stop.size=5) for
15、(int n=1;n+) system.out.println(请输入便道+n+号位汽车的编号,键入$完结); string str01=null; while(true) str01=method.sip(); if(stop.isin(str01) system.out.println(此车已在停车场里,请重新输入!); continue; if(passway.isin(str01) system.out.println(此车已在便道里,请重新输入!); continue; break; if(str01.equals($) break; else car c=new car(); c.
16、car_no=str01; passway.add(c); continue;case 2:system.out.println(请输入待进汽车的编号:); string str02=null; while(true) str02=method.sip(); if(stop.isin(str02) system.out.println(此车已在停车场里,请重新输入!); continue; if(passway.isin(str02) system.out.println(此车已在便道里,请重新输入!); continue; break; car c=new car(); c.car_no=s
17、tr02; if(stop.sizestop.size) system.out.println(此车位尚无汽车!); continue; stop.pop(i2, passway, temp); continue;case 4:system.out.println(请选择查询区域:); system.out.println(1:停车场); system.out.println(2:便道); system.out.println(3:打印全部); int i4=method.iip(1,3); if(i4=1) system.out.println(请输入待查询停车场车位编号:); int i41=method.iip(1,5); if(stop.sizei41) system.out.println(此车位尚无汽车!); else system.out.println(stop.datai41-1.state.tostring(); else if(i4=2) system.out.println(请输入待查询便道车位编
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 【正版授权】 IEC 60122-2:2025 EN-FR Quartz crystal units of assessed quality - Part 2: Guidelines for the use
- 【正版授权】 IEC 63241-2-19:2025 EXV EN Electric motor-operated tools - Dust measurement procedure - Part 2-19: Particular requirements for hand-held jointers
- 黑龙江高三三模数学试卷
- 2025届亳州市重点中学高二物理第二学期期末联考试题含解析
- 2025年中国电池级金属锂行业市场发展前景及发展趋势与投资战略研究报告
- 中国橡胶自粘带市场运行调查报告
- 2025年中国轴用直爪卡簧钳行业市场发展前景及发展趋势与投资战略研究报告
- 2024年免烧砖机项目资金申请报告代可行性研究报告
- 药品网络销售监督管理办法
- 葫芦岛木材加工管理办法
- 他汀不耐受的临床诊断与处理中国专家共识(2024)解读课件
- 2024年7月国家开放大学法学本科《知识产权法》期末考试试题及答案
- 2024移动金融客户端应用软件安全管理规范标准
- DB43T 876.8-2015 高标准农田建设 第8部分:科技服务
- 2025版《新亮剑》高中物理:第九章 静电场及其应用 静电场中的能量含答案
- 普通洗车操作流程及操作指导书
- 40000平方米人民医院项目监理招标文件
- 2024年辽宁电工(高级技师)高频核心题库300题(含解析)
- 北师大版二年级下册竖式计算题练习200道及答案
- JC-T 902-2002 建筑表面用有机硅防水剂
- DL∕T 5539-2018 采动影响区架空输电线路设计规范
评论
0/150
提交评论