停车场管理系统javaWord下载.docx
《停车场管理系统javaWord下载.docx》由会员分享,可在线阅读,更多相关《停车场管理系统javaWord下载.docx(15页珍藏版)》请在冰豆网上搜索。
Stringsip()
Stringstr;
while(true)
{
try
{
str=this.stringinput();
}
catch(IOExceptione)
this.printerror();
continue;
break;
}
intiip(intmin,intmax)
intn=0;
n=this.intinput();
this.printerror();
continue;
catch(NumberFormatExceptione)
if(!
this.between(n,min,max))
break;
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(intlocation,Passwayp,Tempt)
if(location==this.size)
System.out.println(this.peek().car_no+"
号车离开停车场"
this.pop();
else
intf=this.size;
for(inti=1;
=f-location;
t.push(this.peek());
this.pop();
for(inti=0;
!
t.isEmpty();
this.push(t.peek());
t.pop();
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+"
号车进入停车场"
booleanisIn(Strings)
if(size==0)
returnfalse;
for(inti=0;
size;
if(data[i].car_no.equals(s))
privatevoidstretch()
Car[]newData=newCar[data.length*2];
data.length;
newData[i]=data[i];
data=newData;
voidprint()
System.out.println(data[i].state.toString());
publicclassPassway
Car[]data;
intfront;
Passway()
front=0;
booleanisEmpty()
returnsize==0;
publicCarremove()
Carresult=data[front];
front=(front+1)%data.length;
Passwayt=newPassway();
this.size;
t.add(this.data[front+i]);
returnresult;
voidadd(Cartarget)
this.stretch();
data[(front+size)%data.length]=target;
号车位于便道"
号车进入便道"
booleanisIn(Strings)
if(this.data[(front+i)%data.length].car_no.equals(s))
CarnewData[]=newCar[data.length*2];
newData[i]=data[(front+i)%data.length];
System.out.println(data[(front+i)%data.length].state.toString());
publicclassTemp
privateCar[]data;
privateintsize;
Temp()
Carpeek()
Carpop()
号车暂时离开停车场"
publicclasscms
publicstaticvoidmain(Stringargs[])
Stopstop=newStop();
Passwaypassway=newPassway();
Temptemp=newTemp();
Methodmethod=newMethod();
欢迎使用停车场管理系统!
System.out.println("
请选择操作"
1:
初始化"
2:
进车"
3:
出车"
4:
查询"
5:
退出"
intselect=method.iip(1,5);
switch(select)
case1:
inti;
Stopnewstop=newStop();
Passwaynewpassway=newPassway();
stop=newstop;
passway=newpassway;
for(i=1;
=5;
System.out.println("
请输入停车位"
+i+"
号车位汽车的编号,键入$完结"
Stringstr=null;
while(true)
{
str=method.sip();
if(stop.isIn(str))
{
System.out.println("
此车已在停车场里,请重新输入!
continue;
}
if(passway.isIn(str))
此车已在便道里,请重新输入!
}
break;
}
if(str.equals("
$"
))
break;
else
Carc=newCar();
c.car_no=str;
stop.push(c);
if(stop.size==5)
for(intn=1;
n++)
System.out.println("
请输入便道"
+n+"
号位汽车的编号,键入$完结"
Stringstr01=null;
while(true)
str01=method.sip();
if(stop.isIn(str01))
{
System.out.println("
continue;
if(passway.isIn(str01))
}
break;
if(str01.equals("
else
Carc=newCar();
c.car_no=str01;
passway.add(c);
case2:
System.out.println("
请输入待进汽车的编号:
Stringstr02=null;
while(true)
str02=method.sip();
if(stop.isIn(str02))
continue;
if(passway.isIn(str02))
Carc=newCar();
c.car_no=str02;
if(stop.size<
5)
stop.push(c);
else
passway.add(c);
case3:
请输入待出汽车的停车位编号:
inti2;
i2=method.iip(1,5);
if(i2>
stop.size)
此车位尚无汽车!
stop.pop(i2,passway,temp);
case4:
请选择查询区域:
停车场"
2:
便道"
3:
打印全部"
inti4=method.iip(1,3);
if(i4==1)
System.out.println("
请输入待查询停车场车位编号:
inti41=method.iip(1,5);
if(stop.size<
i41)
else
System.out.println(stop.data[i41-1].state.toString());
if(i4==2)
请输入待查询便道车位编号:
inti42=method.iip(1,100);
if(passway.size<
i42)
intii=(i42-1+passway.front)%passway.data.length;
System.out.println(passway.data[ii].state.toString());
stop.print();
passway.print();
case5:
欢迎再次使用!