1、 String sip() String str; while(true) try str=this.stringinput(); catch(IOException e) this.printerror(); continue; break; int iip(int min,int max) int n=0; n=this.intinput(); this.printerror(); continue; catch(NumberFormatException e) if(!this.between(n,min,max) break; return n;public class Car Str
2、ing 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 p,Temp t) if(loc
3、ation=this.size) System.out.println(this.peek().car_no+号车离开停车场 this.pop(); else int f=this.size; for(int i=1;=f-location; t.push(this.peek(); this.pop(); for(int i=0;!t.isEmpty(); this.push(t.peek(); t.pop();p.isEmpty() this.push(p.datap.front); p.remove(); void push(Car target) if(this.isFull() str
4、etch(); datasize=target; size+; target.state=target.car_no+号车位于停车场+size+号位; System.out.println(target.car_no+号车进入停车场 boolean isIn(String s) if(size=0) return false; for(int i=0;size; if(datai.car_no.equals(s) private void stretch() Car newData=new Cardata.length*2;data.length; newDatai=datai; data=n
5、ewData; void print() System.out.println(datai.state.toString();public class Passway Car data; int front; Passway() front=0; boolean isEmpty() return size=0; public Car remove() Car result=datafront; front=(front+1)%data.length; Passway t=new Passway(); this.size; t.add(this.datafront+i); return resu
6、lt; void add(Car target) this.stretch(); data(front+size)%data.length=target;号车位于便道号车进入便道 boolean isIn(String s) if(this.data(front+i)%data.length.car_no.equals(s) Car newData=new Cardata.length*2; newDatai=data(front+i)%data.length; System.out.println(data(front+i)%data.length.state.toString();publ
7、ic class Temp private Car data; private int size; Temp() Car peek() Car pop()号车暂时离开停车场public class cms public static void main(String args) Stop stop=new Stop(); Passway passway=new Passway(); Temp temp=new Temp(); Method method=new Method();欢迎使用停车场管理系统! System.out.println(请选择操作1: 初始化2:进车3:出车4:查询5:退
8、出 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;=5; System.out.println(请输入停车位+i+号车位汽车的编号,键入$完结 String str=null; while(true) str=method.sip(); if(stop.isIn(str) System.out.println(此车已在停车场里,
9、请重新输入! continue; if(passway.isIn(str)此车已在便道里,请重新输入! break; if(str.equals($) break; else Car c=new Car(); c.car_no=str; stop.push(c); if(stop.size=5) for(int n=1;n+) System.out.println(请输入便道+n+号位汽车的编号,键入$完结 String str01=null; while(true) str01=method.sip(); if(stop.isIn(str01) System.out.println( con
10、tinue; if(passway.isIn(str01) break; if(str01.equals( else Car c=new Car(); c.car_no=str01; passway.add(c); case 2:System.out.println(请输入待进汽车的编号: String str02=null; while(true) str02=method.sip(); if(stop.isIn(str02) continue; if(passway.isIn(str02) Car c=new Car(); c.car_no=str02; if(stop.sizestop.
11、size)此车位尚无汽车! stop.pop(i2, passway, temp); case 4:请选择查询区域:停车场2:便道3:打印全部 int i4=method.iip(1,3); if(i4=1) System.out.println(请输入待查询停车场车位编号: int i41=method.iip(1,5); if(stop.sizei41) else System.out.println(stop.datai41-1.state.toString(); if(i4=2)请输入待查询便道车位编号: int i42=method.iip(1, 100); if(passway.sizei42) int ii=(i42-1+passway.front)%passway.data.length; System.out.println(passway.dataii.state.toString(); stop.print(); passway.print(); case 5:欢迎再次使用!
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1