import java.util.ArrayList; /** * A session is defined by the test subjects (students), the room, * the start time, and the duration. Note that duration includes both * the active experiment time and the inter-session turn-around time. * @author Dr. Jody Paul * @version 14 March 2006 */ public class Session { /** The default duration of a session, in minutes. */ public static final int DEFAULT_DURATION = 10; /** The number of test subjects currently assigned to this session. */ private int numberOfSubjects; /** The duration of this session. */ private Time duration; /** The start time of this session. */ private Time startTime; /** The room for this session. */ private Room room; /** The test subjects in this session. */ private java.util.ArrayList testSubjects; /** * Construct Session object with default duration. * Room and start time are set to null. * The list of test subjects is set to the empty list. */ public Session() { numberOfSubjects = 0; duration = new Time(DEFAULT_DURATION); room = null; startTime = null; testSubjects = new ArrayList(); } /** * Construct Session object with specified duration. * Room and start time are set to null. * The list of test subjects is set to the empty list. * @param theDuration the duration */ public Session(Time theDuration) { numberOfSubjects = 0; duration = theDuration; room = null; startTime = null; testSubjects = new ArrayList(); } /** * Construct Session object with specified duration, room and start time. * The list of test subjects is set to the empty list. * @param theDuration the duration * @param theRoom the room * @param theStartTime the start time */ public Session(Time theDuration, Room theRoom, Time theStartTime) { numberOfSubjects = 0; duration = theDuration; room = theRoom; startTime = theStartTime; testSubjects = new ArrayList(); } /** * Return the number of test subjects currently assigned to this session. * @return the number of subjects */ public int getNumberOfSubjects() { return numberOfSubjects; } /** * Return the duration of this session. * @return the duration */ public Time getDuration() { return duration; } /** * Return the start time of this session. * @return the start time */ public Time getStartTime() { return startTime; } /** * Return the room of this session. * @return the room */ public Room getRoom() { return room; } /** * Return the test subjects in this session. * @return the test subjects */ public ArrayList getSubjects() { return testSubjects; } /** * Return a specific test subject. * @param which the index of the test subject * @return the test subject at index "which" */ public Student getSubject(int which) { return testSubjects.get(which); } /** * Change the duration of this session. * @param newDuration the new duration (in minutes) */ public void setDuration(Time newDuration) { duration = newDuration; } /** * Change the start time of this session. * @param newStartTime the new start time */ public void setStartTime(Time newStartTime) { startTime = newStartTime; } /** * Change the room of this session. * @param newRoom the new room */ public void setRoom(Room newRoom) { room = newRoom; } /** * Change the test subjects in this session. * @param newSubjects the new test subjects */ public void setSubjects(ArrayList newSubjects) { testSubjects = newSubjects; numberOfSubjects = testSubjects.size(); } /** * Add a test subject. * @param newSubject the new test subject */ public void addSubject(Student newSubject) { testSubjects.add(newSubject); numberOfSubjects = testSubjects.size(); } }