/* -------------------------------------------------------- * * Aaron Morris * * CS567 * * Object-Oriented Event-Driven Simulation * * * * Basic Event class for the Simulation. Extend this class * * for each type of event in the simulation. * * -------------------------------------------------------- */ //package datasend; import java.awt.*; public class SimEvent { /* members */ protected String eventType; // String representing the type of event protected int ID; // Integer ID value for reporting clarity protected int arrivalTime; // Time event is to arrive protected int sortValue; // Value to sort on -- sort on Arrival protected SimEvent next; // Next Object in Linked List protected Message message; // Message of Event protected DataHandler Creator; // Event Creator // Basic Object Constructor. Does nothing, override in child classes public SimEvent() { } // General Methods to return/set attributes public String getEventType() { return this.eventType; } public Message getMessage() { return this.message; } public int getArrivalTime() { return this.arrivalTime; } public int getID() { return this.ID; } public int getSortVal() { return this.sortValue; } public SimEvent getNext() { return this.next; } public void setNext(SimEvent ev) { this.next = ev; } public void setID(int ID) { this.ID = ID; } // This will create a String representation of an event for reporting public String getStringRep() { return "[" + eventType + " #" + getID() + "," + arrivalTime + "]"; } // Instructions for a SimEvent object's invocation // This is blank because it is overridden in all child classes public void execute(EventQueue e, Stats s, int x, RandNum randGen) { } public void writeExecute(int Time, Stats s) { String outString = new String(); outString = eventType + " From " + this.Creator.getName() + " at Time " + Time + " MessageID = " + message.getMsgID(); s.report.write(outString); } }