This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
PF3/hw1/Ex2/src/semaphore/Car.java

31 lines
530 B
Java

package semaphore;
import java.util.Random;
public class Car {
// Simulated max time taken by a valet to park a car
private static final int MAX_PARKING_TIME = 3000;
private final int plate;
private static final Random generator = new Random();
public Car(int plate) {
this.plate = plate;
}
public int getPlate() {
return plate;
}
public void park() throws Exception {
int time = generator.nextInt(MAX_PARKING_TIME);
Thread.sleep(time);
}
@Override
public String toString() {
return "" + plate;
}
}