        // An event denoting the arrival (creation) of a new Driver
        // at the gas station.

class DriverArrival extends Event {
    public DriverArrival(long eventTime,GasStation f){
        super(eventTime);
        station = f;
    }

    public void perform(Scheduler scheduler){
        GasStation station = getStation();
        // Schedule the next arrival.
        long now = scheduler.getTime();
        scheduler.schedule(new DriverArrival(nextArrivalTime(now),station));

        Driver d = new Driver(station);
        // Register this event with the driver for the record.
        d.addEvent(this);

        // Let the gas station know a new driver has arrived.
        station.arrival(d);
    }

    public String toString(){
        return getWhen()+" DriverArrival";
    }

        // Calculate when the next driver should arrive.
    protected long nextArrivalTime(long now){
        // Simulate a Poisson distribution of arrivals.
        return now + (long)(-meanArrivalTime*Math.log(Math.random()));
    }

    protected GasStation getStation(){
        return station;
    }

    // Mean arrival time of drivers, in seconds.
    private final double meanArrivalTime = 60.0;
    private final GasStation station;
}
