Class Clock
java.lang.Object
|
+--Clock
- public class Clock
- extends java.lang.Object
The clock used to run the lunch simulation. It uses a Priority
Queue to hold a series of Events. These events all occur at a
certain time.
- See Also:
PriorityQueue
,
Event
Field Summary |
private double |
currentTime
The current time in the simulation: time passed since the start
of lunch. |
private PriorityQueue |
timer
The structure used to store events. |
Constructor Summary |
Clock()
Creates a new Clock. |
Clock(double initTime)
Creates a new Clock, with a specified starting time |
Method Summary |
void |
addEvent(Event event,
double time)
Adds a specified event at a certain time to the simulation clock |
boolean |
finished()
Checks if there are no more events in the simulation |
double |
getCurrentTime()
Returns the current time |
Event |
nextEvent()
Returns the next event from the simulation |
Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
toString,
wait,
wait,
wait |
currentTime
private double currentTime
- The current time in the simulation: time passed since the start
of lunch.
timer
private PriorityQueue timer
- The structure used to store events.
Clock
public Clock(double initTime)
- Creates a new Clock, with a specified starting time
- Parameters:
initTime
- the Clock's starting time
Clock
public Clock()
- Creates a new Clock. The starting time is set to 0
getCurrentTime
public double getCurrentTime()
- Returns the current time
addEvent
public void addEvent(Event event,
double time)
- Adds a specified event at a certain time to the simulation clock
- Parameters:
event
- the Event to be added to the simulationtime
- the time the event is to occur
nextEvent
public Event nextEvent()
- Returns the next event from the simulation
finished
public boolean finished()
- Checks if there are no more events in the simulation
- Returns:
- true iff there are no more events in the simulation