/** A class that generates random events, and creates students to be processed by the simulation @author Erika Harrison @version 1.0 24-06-02 */ public class Server { private Student nextStudent = null; private double nextTime = 0; //generates a random next value, as requested by server classes protected RandomInterface generateNextTime = null; protected double mean; //constructs a server object public Server() { super(); } public void setRandom(long seed, double mean) //pre: true //post: the random object associated with the server is constructed according // to the seed & mean parameters { generateNextTime = DataFactory.makeRandom(seed); this.mean = mean; } public double getNextTime() //pre: true //post: returns the time of the next event { return nextTime; } public void setNextEvent(double currTime) //pre: currTime == the current time in the system; a previous event has just // been processed //post: the next event is determined for the server (a new student is created // and their time of entering the system is established { setTime(generateNextTime.nextExp(mean) + currTime); nextStudent = new Student(nextTime); } public Student getStudent() //pre: true //post: returns the current student under going processing { return nextStudent; } public void setStudent(Student student) //pre: true //post: the student under going processing is set to student { nextStudent = student; } public void setTime(double time) //pre: true //post: sets the time of the next event (accessible to any extending classes) { nextTime = time; } public Student removeStudent() //pre: true //post: removes and returns the student currently undergoing processing at the // server (aids in preventing duplication of pointers) { Student temp = nextStudent; nextStudent = null; return temp; } }