Question: This task is simple: you need to complete the constructor and the getter / setter methods of the Spot class. An instance of Spot stores
This task is simple: you need to complete the constructor and the getter / setter methods of the Spot class. An instance of Spot stores not only a reference variable of type Car but also a primitive integer, timestamp, to keep track of when a car got parked in the lot. Through this timestamp, we can calculate the duration that a car has been parked in the lot and subsequently how probable the car is to leave at any point in time. We further use the Spot class to capture arrivals in the entrance and exit queues. When instances of Spot are put into either of the two queues, the timestamp value denotes the time (simulation iteration) when the associated car was put in the queue.
public class Spot {
private Car car;
private int timestamp;
public Car getCar() {
return car;
}
public void setCar(Car car) {
this.car = car;
}
public int getTimestamp() {
return timestamp;
}
public void setTimestamp(int timestamp) {
this.timestamp = timestamp;
}
public Spot(Car car, int timestamp) {
// WRITE YOUR CODE HERE!
}
/**
* Returns a string representation of the spot
* This method is complete; you do not need to change it.
*/
public String toString() {
return car + ", timestamp: " + timestamp;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
