Class EventTimer

java.lang.Object
  |
  +--EventTimer

public class EventTimer
extends java.lang.Object

A class used to assign random times to all of the events which take place in the lunch-seating simulation. Because two seating schemes will be compared, it is important that both schemes have the same input: that each party which will arrive has the same arrival time between schemes, and that both eating times are equivalent. This may be accomplished by seeding the random number generators.

See Also:
Party, Clock, Event

Field Summary
private  java.util.Random arrivalTimer
          A random number generator to generate arrival times
private  java.util.Random eatingTimer
          A random number generator to generate eating times
static int LUNCH_TIME
          The number of minutes that lunch is served on the cruise ship
static int MAX_EATING_TIME
          The maximum amount of time a party can take to eat their lunch
static int MIN_EATING_TIME
          The minimum amount of time a party can take to eat their lunch
 
Constructor Summary
EventTimer()
          Creates a new, non-seeded EventTimer
EventTimer(long seed1, long seed2)
          Creates a new EventTimer.
 
Method Summary
 double nextArrivalTime()
          Returns a pseudo-random number in the range [0, LUNCH_TIME]
 double nextEatingTime()
          Returns a pseudo-random number in the range [MIN_EATING_TIME, MAX_EATING_TIME]
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

MIN_EATING_TIME

public static final int MIN_EATING_TIME
The minimum amount of time a party can take to eat their lunch

MAX_EATING_TIME

public static final int MAX_EATING_TIME
The maximum amount of time a party can take to eat their lunch

LUNCH_TIME

public static final int LUNCH_TIME
The number of minutes that lunch is served on the cruise ship

arrivalTimer

private java.util.Random arrivalTimer
A random number generator to generate arrival times

eatingTimer

private java.util.Random eatingTimer
A random number generator to generate eating times
Constructor Detail

EventTimer

public EventTimer()
Creates a new, non-seeded EventTimer

EventTimer

public EventTimer(long seed1,
                  long seed2)
Creates a new EventTimer. The parameters are used to seed the pseudo-random number generators which are used to produce the various times.
Parameters:
seed1 - the seed for the arrival timer
seed2 - the seed for the eating timer
Method Detail

nextArrivalTime

public double nextArrivalTime()
Returns a pseudo-random number in the range [0, LUNCH_TIME]

nextEatingTime

public double nextEatingTime()
Returns a pseudo-random number in the range [MIN_EATING_TIME, MAX_EATING_TIME]