停车场管理系统(java)_第1页
停车场管理系统(java)_第2页
停车场管理系统(java)_第3页
停车场管理系统(java)_第4页
停车场管理系统(java)_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论