Class AbstractEvent

java.lang.Object
  extended by AbstractEvent
All Implemented Interfaces:
Event, java.lang.Comparable<Event>
Direct Known Subclasses:
ArrivalEvent, DepartureEvent, SimulationEndEvent, SimulationReportEvent

public abstract class AbstractEvent
extends java.lang.Object
implements Event, java.lang.Comparable<Event>

Abstract class for simulation events.
COMP 2100
Project 3
October 2014


Field Summary
 
Fields inherited from interface Event
ARRIVAL_PRIORITY, DEPARTURE_PRIORITY, SIMULATIONEND_PRIORITY, SIMULATIONREPORT_PRIORITY
 
Constructor Summary
protected AbstractEvent(int time, int priority)
          Constructor, only accessible to subclasses.
 
Method Summary
 int compareTo(Event e)
          Compares this event to the given event.
 int getPriority()
          Retrieves the event's priority.
 int getTime()
          Retrieves the event's scheduled time.
protected  void setPriority(int priority)
          Sets the event's priority.
protected  void setTime(int time)
          Set the event's scheduled time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Event
process
 

Constructor Detail

AbstractEvent

protected AbstractEvent(int time,
                        int priority)
Constructor, only accessible to subclasses.

Parameters:
time - The event's scheduled time.
priority - The event's priority.
Method Detail

getTime

public int getTime()
Retrieves the event's scheduled time. This is required by the Event interface.

Specified by:
getTime in interface Event
Returns:
The event's scheduled time.

getPriority

public int getPriority()
Retrieves the event's priority. A larger value means higher priority. This is required by the Event interface.

Specified by:
getPriority in interface Event
Returns:
The event's priority.

setTime

protected void setTime(int time)
Set the event's scheduled time. Only an object from a subclass can do this.

Parameters:
time - The event's scheduled time.

setPriority

protected void setPriority(int priority)
Sets the event's priority. A larger value means higher priority. Only an object from a subclass can do this.

Parameters:
priority - The event's priority.

compareTo

public int compareTo(Event e)
Compares this event to the given event. This is required by the CompareTo interface. If this event has a lower (earlier) time, the value returned is less than zero. If this event has a higher (later) time, the value returned is greater than zero. If both events have the same time, then the result is based on priority. If this event has a lower priority, the value returned is greater than zero. If this event has a higher priority, the value returned is less than zero. If both the time and priority are the same, the value returned is zero.

Specified by:
compareTo in interface java.lang.Comparable<Event>
Parameters:
e - The event this one is compared to
Returns:
a value which is either less than, equal to, or greater than, zero. The determination is described above.