package jutil; /** * Used by the Sim framework to represent events in * a simulation. */ public class Event implements Comparable, java.io.Serializable { /** * The time when this event will occur. */ protected int fireTime; /** * Initializes fireTime. */ public Event(int time) { fireTime = time; } /** * Sets fire time to 0. */ public Event() { this(0); } /** * this is less than other if this.fireTime is before * other.fireTime. * @param other an event to compare with this event. * @return a negative number if this event is before other event, * a positive number if this event is after other, and * 0 if both occur at the same time. */ public int compareTo(Object other) { if (! (other instanceof Event)) throw new ClassCastException(); Event e = (Event)other; return fireTime - e.fireTime; } /** * @return firing time */ public int getFireTime() { return fireTime; } /** * Override this method in subclasses. * @return A subsequent event to be scheduled or null. */ public Event fire() { return null; } /** * @return {fireTime} */ public String toString() { return "{" + fireTime + "}"; } }