m865.simulation
Class Event

java.lang.Object
  extended by m865.simulation.Event
All Implemented Interfaces:
java.lang.Comparable, Prioritizeable
Direct Known Subclasses:
DepartmentStoreEvent

public abstract class Event
extends java.lang.Object
implements Prioritizeable

Abstract class for an event. It defines the basic methods for any event in a discrete event simulation.


Field Summary
protected  java.lang.Integer firingTime
          Every event has a time at which it fires
 
Constructor Summary
Event(java.lang.Integer firingTime)
          Constructor for an event
 
Method Summary
 boolean adjustPriority(java.lang.Comparable obj)
          A prioritizable object can have its priority raised or lowered.
 int compareTo(java.lang.Object obj)
          The compareTo method required by the Comparable interface If the priorities are comparable this returns an int specifying the relation between the two priorities.
abstract  void fire()
          This method is invoked when it is time for an event to fire.
 java.lang.Integer getFiringTime()
          Gets the firing time for this event.
 void setFiringTime(java.lang.Integer newTime)
          Set a new firing time for this event.
 java.lang.String toString()
          The basic toString method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

firingTime

protected java.lang.Integer firingTime
Every event has a time at which it fires

Constructor Detail

Event

public Event(java.lang.Integer firingTime)
Constructor for an event

Parameters:
firingTime - the time at which this event is scheduled to fire.
Method Detail

getFiringTime

public java.lang.Integer getFiringTime()
Gets the firing time for this event.

Returns:
the time that this event is scheduled to fire.

setFiringTime

public void setFiringTime(java.lang.Integer newTime)
Set a new firing time for this event.

Parameters:
newTime - the new time for this event to fire.

fire

public abstract void fire()
This method is invoked when it is time for an event to fire.


adjustPriority

public boolean adjustPriority(java.lang.Comparable obj)
A prioritizable object can have its priority raised or lowered.

Specified by:
adjustPriority in interface Prioritizeable
Parameters:
obj - a Comparable object appropriate for specifying the priority. This method will throw a ClassCastException if the new priority is not an Integer.
Returns:
true if this object has a priority that is equal to or higher than before.

compareTo

public int compareTo(java.lang.Object obj)
The compareTo method required by the Comparable interface If the priorities are comparable this returns an int specifying the relation between the two priorities.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - the specified object which should be a PrioritizedItem
Returns:
a negative integer if this object should appear before the specified object in a sorted list; zero if this object is equal to the specified object; and a positive integer if this object should appear after the specified object in a sorted list.

toString

public java.lang.String toString()
The basic toString method

Overrides:
toString in class java.lang.Object
Returns:
a string identifying this event.