============================================ import java.util.

*; interface Vehicle{ public int getSize(); } class Car implements Vehicle{ public int getSize(){ return carSize; } private int carSize=5; } class Truck implements Vehicle{ public int getSize(){ return truckSize; } private int truckSize=10;

Parking

}

class ShowRoomManagement{ int used=0; public void park(){ int int int int int count=0; count1=0; count2=0; a=0; b=0;

Random rn = new Random(); while(count<100){ int r=rn.nextInt(2); if(r==0){

Sucessfully!!"); } else{

showRoom[used]=c1; System.out.println("Car count1++;

is Parked

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"); } public void parkOut(){ System.out.println("You want to Park Out Car or Truck"); System.out.println("1-Car"); System.out.println("2-Truck"); System.out.println("3-Menu"); Scanner sc=new Scanner(System.in); int s=sc.nextInt(); int z=0; if(s==1){ for(int i=0;i<used;i++) if(showRoom[i]==c1) for(int k=i;k<used;k++) showRoom[k-1]=showRoom[k]; } if(s==2){ for(int j=0;j<used;j++) used--;

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"); } public void showMotors(){ System.out.println("\nShow All Motors that are Parked\n"); for(int i=0;i<used;i++){ if(showRoom[i]==c1) System.out.println("Car"); else System.out.println("Truck"); } System.out.println("\n"); } public void menu(){ for(;;){ System.out.println("1-Park"); System.out.println("2-Park Out"); System.out.println("3-Show Motors"); System.out.println("4-Quit"); System.out.println("Enter ur choice: "); Scanner sc=new Scanner(System.in); int s=sc.nextInt(); if(s==1) park(); if(s==2)

}

parkOut(); if(s==3) showMotors(); if(s==4) System.exit(0); }

}

private Vehicle showRoom[]=new Vehicle[20]; private Car c1=new Car(); private Truck t1=new Truck();

class Parking{ public static void main(String args[])throws ArrayIndexOutOfBoundsException{ ShowRoomManagement srm=new ShowRoomManagement(); srm.menu(); } }

http://www.ravianeducation.blogspot.com FARHAN: 03008855006