Question: The Vehicle class has private data for String license, int hours, and int minute. It offers a default constructor, parameterized constructor, accessors, mutators, toString, and

The Vehicle class has private data for String license, int hours, and int minute. It offers a default constructor, parameterized constructor, accessors, mutators, toString, and equals. This source code file Vehicle.java is available for your use. Do not edit this class.
Processing: A parking lot company owns a small alley between two buildings that can park 4 cars. The alley is only open at one end. The alley is so narrow that entrance and exit uses LIFO behavior so is modelled with a Java Stack object. When a car arrives and there is room, it is pushed onto the stack. If there is no room it is turned away and drives off without being processed. When a request comes in for a departure, the attendant looks at the car and reports the position with a message to the driver (see sample output). If the car is not in the alley, report message. Cars are backed out and parked temporarily on the street. The temporary street parking is modelled with an ArrayList object. Once the car pays its bill and drives away, the cars parked temporarily on the street are reparked in the alley. The order in which they are reparked is irrelevant. At the end of the day report cars left in the alley. The parking list charges $6.00 per hour and cars are charged by the minute.
This interactive program uses a sentinel controlled while loop, using sentinel "Q" to stop the loop. Here is an example of writing an algorithm. I suggest you write your algorithm to designate the tasks and their order in English prior to coding.
Code can assume valid data is entered so no error checking is needed. The workday runs from 06:00 to 18:00 so no code needs to be written to process times that cross midnight
Get the first code (A for Arrival, D for Departure, Q for Quit)
While the code is not Q :
If the code is A for Arrival:
If alley is full
Report message and car drives away
Else
Get license and arrival time and make Vehicle object
Push this vehicle to alley
Report transaction
If the code is D for Departure
Get license and departure time and make Vehicle object
Get position of this vehicle in the alley stack using Java Stack search method
Report the position and appropriate message (see sample output) based on position
Pop cars up to desired car and park temporarily on the street in the list
Pop the car that is departing and report cost
Push the cars from temporary parking back onto the alley stack
Get the next code at loop bottom
Display licenses of remaining cars in the alley
Sample Output:
Enter code (A for Arrival, D for Departure, Q to quit): A
Enter license: aaaaa
Enter time (hh:mm): 06:00
Car with license aaaaa parked at 6:00
Enter code (A for Arrival, D for Departure, Q to quit): A
Enter license: bbbbbb
Enter time (hh:mm): 06:30
Car with license bbbbbb parked at 6:30
Enter code (A for Arrival, D for Departure, Q to quit): A
Enter license: cccc
Enter time (hh:mm): 07:30
Car with license cccccc parked at 7:30
Enter code (A for Arrival, D for Departure, Q to quit): A
Enter license: dddddd
Enter time (hh:mm): 08:00
Car with license ddddd parked at 8:00
Enter code (A for Arrival, D for Departure, Q to quit): A
Enter license: eeeeee
Enter time (hh:mm): 08:15
Car with license eeeeee turned away at 8:15- LOT IS FULL
Enter code (A for Arrival, D for Departure, Q to quit): D
Enter license: dddddd
Enter time (hh:mm): 08:30
Your car is in position 1
There will be no wait, advance to cashier
Car with license ddddd left at 8:30 paying $3.00
Enter code (A for Arrival, D for Departure, Q to quit): D
Enter license: aaaaa
Enter time (hh:mm): 09:00
Your car is in position 3
Please be patient while we retrieve your car
Car with license aaaaa left at 9:00 paying $18.00
Enter code (A for Arrival, D for Departure, Q to quit): D
Enter license: zzzzzz
Enter time (hh:mm): 10:00
Your car is not parked here, sorry...
Enter code (A for Arrival, D for Departure, Q to quit): Q
Remaining Cars in the Alley:
bbbbbb
ccccc
 The Vehicle class has private data for String license, int hours,

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 Databases Questions!