Question: Generate Random Decals is primitive please fix that as well As a license plate number, integers are to be used. Positive numbers

Generate Random Decals is primitive please fix that as well

 

 

 

As a license plate number, integers are to be used. Positive numbers add a car, negative numbers remove a car, zero stops the simulation. License plates should have 5 digits. For example, if I am attempting to park my car I would enter my license plate as 05697. When I'm ready to retrieve my call, I would enter -05697. The positive number tells the program that I wish to park my car, prompting the program to check the randomly generated decal type. The program should tell me if I have the correct decal and if there is room to park my car. If the stack representing the parking lot is full, my car should be added to the waiting queue.

 

If I remove my car by entering -05697, the next car in the queue should be parked before a new car can be entered unless the queue is empty. The status of the parking lot and the waiting queue should be printed to the console after each operation is complete. The status includes the cars that are parked in the lot as well as the cars that are currently waiting in the queue to park.

 

 

import java.util.LinkedList;

import java.util.List;

import java.util.Queue;

import java.util.Random;

import java.util.Scanner;

import java.util.Stack;


 

//


 

public class FIUParkingTester {

private static Scanner scan;


 

/**

* @param

* @param args

*/

public static void main(String[] args) {


 

int numOfSpots = 15; // number of spots in the parkingLot

 

Stack parkinglot = new Stack<>();

Stack street = new Stack<>();

Queue waitingCars = new LinkedList<>();

 

scan = new Scanner(System.in);

 

int licensePlate;


 

for(int i = 0; i < 10; i++) { // loop over with a sets conditions that 10 cars have already parked in the parkinglot

 

final Car car = new Car();

System.out.println("Welcome to the FIU PC Parking Lot");

System.out.println(" ");

}


 

do {

System.out.println("Please enter license plate number:");

licensePlate = scan.nextInt();

System.out.println("Get Decal");


 

if (parkinglot.size() <=numOfSpots) {

waitingCars.add(licensePlate);

System.out.println("Parking lot is full. Car is added to queue.");

}

else {

parkinglot.add(licensePlate);

Random rnd = new Random(); // random number generator



 

int decal = rnd. nextInt(10000); // convert the get a random number of decal

String decals=Integer.toString(decal);

licensePlate.setDecal(licensePlate.generateRandomDecal);


 

System.out.println("You've parked your car at the PC building " + licensePlate);

}

//retrieve = the following

while(parkinglot.peek()!= licensePlate){

street.push(parkinglot.peek());

parkinglot.pop();

}

// boolean = the following where to print false for on the two stacks and queue

parkinglot.pop();

while(!street.empty()){

parkinglot.push(street.peek());

street.pop();

}

if(waitingCars.size() > 0){

parkinglot.push(waitingCars.remove());

 

}


 

}


 

while(numOfSpots > 0);

 

scan.close();



 

}


 

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!