Parking Example - JAVA
Parking Example - JAVA
Parking Example - JAVA
============================================
import java.util.*;
interface Vehicle{
public int getSize();
}
class ShowRoomManagement{
int used=0;
public void park(){
int count=0;
int count1=0;
int count2=0;
int a=0;
int b=0;
while(count<100){
int r=rn.nextInt(2);
if(r==0){
showRoom[used]=c1;
System.out.println("Car is Parked
Sucessfully!!");
count1++;
}
else{
if(count<=90){
showRoom[used]=t1;
System.out.println("Truck is Parked
Sucessfully!!");
count2++;
}
}
a=count1*c1.getSize();
b=count2*t1.getSize();
count=a+b;
System.out.println("Space: "+count);
used++;
}
System.out.println("\nParking is Full!!\n");
}
used--;
}
if(s==2){
for(int j=0;j<used;j++)
if(showRoom[j]==t1)
for(int a=j;a<used;a++)
showRoom[a-1]=showRoom[a];
used--;
}
if(s==3)
menu();
System.out.println("\nShow All Motors that are
Parked\n");
for(int p=0;p<used;p++){
if(showRoom[p]==c1)
System.out.println("Car");
else
System.out.println("Truck");
}
System.out.println("\n");
}
if(s==1)
park();
if(s==2)
parkOut();
if(s==3)
showMotors();
if(s==4)
System.exit(0);
}
}
class Parking{
public static void main(String args[])throws
ArrayIndexOutOfBoundsException{
ShowRoomManagement srm=new
ShowRoomManagement();
srm.menu();
}
}
http://www.ravianeducation.blogspot.com
FARHAN: 03008855006