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 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.
public class Vehicle {
private String license; // license plate
private int hour; // hour (24 hour time)
private int minutes; // minutes (0..59)
public Vehicle()
{ license =""; hour =0; minutes =0;
}
public Vehicle(String s, int h, int m)
{ license = s; hour = h; minutes = m;
}
public String getLicense(){
return license; }
public void setLicense(String license){
this.license = license; }
public int getHour(){
return hour; }
public void setHour(int hour){
this.hour = hour; }
public int getMinutes(){
return minutes; }
public void setMinutes(int 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 equals(Object other)
{ Vehicle temp =(Vehicle)(other);
return temp.getLicense().equals(license);
}
}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 06:00 to
18:00 so no code needs to be written to process times that cross midnight
package Main; The Vehicle class has private data

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!