Question: package Main; The Vehicle class has private data for String license, int hours, and int minute. It offers a default constructor, parameterized constructor, accessors, mutators,
package Main; 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 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 $ per hour and cars are charged by the minute.
public class Vehicle
private String license; license plate
private int hour; hour hour time
private int minutes; minutes
public Vehicle
license ; hour ; minutes ;
public VehicleString s int h int m
license s; hour h; minutes m;
public String getLicense
return license;
public void setLicenseString license
this.license license;
public int getHour
return hour;
public void setHourint hour
this.hour hour;
public int getMinutes
return minutes;
public void setMinutesint minutes
this.minutes minutes;
return string representation of data
public String toString
return license hour : minutes;
return true if other car has same license as object
public boolean equalsObject other
Vehicle temp Vehicleother;
return temp.getLicenseequalslicense;
This interactive program uses a sentinel controlled while loop, using sentinel Q to stop the loop.
Code can assume valid data is entered so no error checking is needed. The workday runs from : to
: so no code needs to be written to process times that cross midnight
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
