欢迎来到天天文库
浏览记录
ID:48360831
大小:28.72 KB
页数:12页
时间:2019-11-16
《停车场管理系统java.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、importjava.io.*;publicclassMethod{privateintintinput()throwsIOException,NumberFormatException{BufferedReaderbr=newBufferedReader(newInputStreamReader(System.in));Stringstr=br.readLine();inti=Integer.parseInt(str);returni;}privateStringstringinput()throwsIOException{BufferedReaderbr=newBuffered
2、Reader(newInputStreamReader(System.in));Stringstr=br.readLine();returnstr;}privatebooleanbetween(intn,intmin,intmax){for(inti=min;i<=max;i++)if(n==i)returntrue;returnfalse;}privatevoidprinterror(){System.out.println("输入错误!请重新输入!");}Stringsip(){Stringstr;while(true){try{str=this.stringinput();}
3、catch(IOExceptione){this.printerror();continue;}break;}returnstr;}intiip(intmin,intmax){intn=0;while(true){try{n=this.intinput();}catch(IOExceptione){this.printerror();continue;}catch(NumberFormatExceptione){this.printerror();continue;}if(!this.between(n,min,max)){this.printerror();continue;}b
4、reak;}returnn;}}publicclassCar{Stringcar_no;Stringstate;Car(){car_no=null;state=null;}}publicclassStop{Cardata[];intsize;Stop(){data=newCar[1];size=0;}privateCarpeek(){returndata[size-1];}privatebooleanisFull(){returnsize==data.length;}privateCarpop(){size--;returndata[size];}voidpop(intlocati
5、on,Passwayp,Tempt){if(location==this.size){System.out.println(this.peek().car_no+"号车离开停车场");this.pop();}else{intf=this.size;for(inti=1;i<=f-location;i++){t.push(this.peek());this.pop();}System.out.println(this.peek().car_no+"号车离开停车场");this.pop();for(inti=0;!t.isEmpty();i++){this.push(t.peek())
6、;t.pop();}}if(!p.isEmpty()){this.push(p.data[p.front]);p.remove();}}voidpush(Cartarget){if(this.isFull())stretch();data[size]=target;size++;target.state=target.car_no+"号车位于停车场"+size+"号位";System.out.println(target.car_no+"号车进入停车场"+size+"号位");}booleanisIn(Strings){if(size==0)returnfalse;for(inti
7、=0;i
此文档下载收益归作者所有