1、停车场管理系统java-标准化文件发布号:(9556-EUATWK-MWUB-WUNN-INNUL-DDQTY-KII停车场管理系统(java)import java.io.*;public class Method private int intinput() throws IOException,NumberFormatException BufferedReader br=new BufferedReader(new InputStreamReader(System.in); String str=br.readLine(); int i=Integer.parseInt(str); r
2、eturn i; private String stringinput() throws IOException BufferedReader br=new 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() Sy
3、stem.out.println(输入错误!请重新输入!); String sip() String str; while(true) try str=this.stringinput(); catch(IOException e) this.printerror(); continue; break; return str; int iip(int min,int max) int n=0; while(true) try n=this.intinput(); catch(IOException e) this.printerror(); continue; catch(NumberForm
4、atException e) this.printerror(); continue; if(!this.between(n,min,max) this.printerror(); continue; break; 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;
5、 private boolean isFull() return size=data.length; private Car pop() size-; return datasize; void pop(int location,Passway p,Temp t) if(location=this.size) System.out.println(this.peek().car_no+号车离开停车场); this.pop(); else int f=this.size; for(int i=1;i=f-location;i+) t.push(this.peek(); this.pop(); S
6、ystem.out.println(this.peek().car_no+号车离开停车场); this.pop(); for(int i=0;!t.isEmpty();i+) this.push(t.peek(); t.pop(); if(!p.isEmpty() this.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.
7、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; return 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
8、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() return size=0; private boolean isFull() return size=data.length; public Car remove() Car result=datafront; front=(front+1)%data.len
9、gth; 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.length=target; size+; target.state=target.car_no+号车位于便道+size+号位; System.out.println(target.car_no+号车进入便道+size+号位); boole
10、an 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.length*2; for(int i=0;idata.length;i+) newDatai=data(front+i)%data.length; data=newData; front=0; void print()
11、 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 peek() return datasize-1; private boolean isFull() return size=data.length; Car pop() size-;
12、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.length*2; for(int i=0;idata.length;i+) newDatai=datai; data=newData; public cla
13、ss 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(欢迎使用停车场管理系统!); while(true) System.out.println(请选择操作); System.out.println(1: 初始化); System.out.println(2:进车); System.out.println(3:出车);
14、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(请输入停车位+i+号车位汽车的编号,键入$完结); String str=null; while(true) str=meth
15、od.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(int n=1;n+) System.out.println(请输入便道+n+号位汽车的编号,键入$完结); St
16、ring 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.car_no=str01; passway.add(c); continue; case 2:System.out.
17、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=str02; if(stop.sizestop.size) System.out.println(此车位尚无汽车!)
18、; 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(此
19、车位尚无汽车!); else System.out.println(stop.datai41-1.state.toString(); else if(i4=2) System.out.println(请输入待查询便道车位编号:); int i42=method.iip(1, 100); if(passway.sizei42) System.out.println(此车位尚无汽车!); else int ii=(i42-1+passway.front)%passway.data.length; System.out.println(passway.dataii.state.toString(); else stop.print(); passway.print(); continue; case 5:System.out.println(欢迎再次使用!); break;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1