Class Schedules

java.lang.Object
  |
  +--Schedules

public class Schedules
extends java.lang.Object

Contains seven templates to represent an entire week


Field Summary
private  Templates[] daysOfWeek
          Seven templates that make up all of the days of the week
 
Constructor Summary
Schedules()
          Constructs an empty schedule
Schedules(java.lang.String fileName)
          Constructs a schedule from a file
 
Method Summary
 void AddShift(int day, Shifts toAdd)
          Adds a shift to the schedule on a specific day
 void Generate(ListOfEmployees employeesList)
          The Generate() function consists of two passes: During the first pass, the list of employees is traversed linearly.
 java.util.Vector GetShifts(int day)
          Gets all of the shifts on a particular day
 void LoadTemplate(int day, java.lang.String fileName)
          Loads a template into a specific day
 void Optimize(ListOfEmployees employeesList)
          The function Optimize is called in the Generate function.
 void RemoveShift(int day, Shifts toRemove)
          Removes a shift from the schedule on a specific day
 void SaveTemplate(int day, java.lang.String fileName)
          Saves a template from a specific day into a specific file
 void SetEmployee(int day, Shifts toSet, Employees newEmployee)
          Sets an employee to a shift on a specified day
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

daysOfWeek

private Templates[] daysOfWeek
Seven templates that make up all of the days of the week
Constructor Detail

Schedules

public Schedules()
Constructs an empty schedule

Pre-conditions: none
Post-conditions: The private array of Templates is initialized for this class.


Schedules

public Schedules(java.lang.String fileName)
Constructs a schedule from a file

Pre-conditions: A valid variable of type String is passed.
The passed name is for a valid file that exists.
Post-conditions: The private array of Templates is set according to the file.

Parameters:
fileName - the file that contains the schedule information
Method Detail

LoadTemplate

public void LoadTemplate(int day,
                         java.lang.String fileName)
Loads a template into a specific day

Pre-conditions: Valid variables of types int and String are passed.
The passed int is a valid day of the week and
the passed name is for a valid file that exists.
Post-conditions: Load a template into the schedule

Parameters:
day - day to load template into (i.e. 1=Monday,...)
fileName - name of file that contains the template information

SaveTemplate

public void SaveTemplate(int day,
                         java.lang.String fileName)
Saves a template from a specific day into a specific file

Pre-conditions: Valid variables of type int and String are passed.
The passed int is a valid day of the week.
Post-conditions: The template for the indicated day is saved to a file of the passed name.

Parameters:
day - day to capture template from
fileName - file to save template to

Generate

public void Generate(ListOfEmployees employeesList)
The Generate() function consists of two passes: During the first pass, the list of employees is traversed linearly. That employees are selected one after another, And the shifts are filled on a best effort try; For the second pass, Generate() can call the Optimize() function and arbitrary number of times. Optimize permutates employees who are already scheduled and those who are not. These permutations are done to fill as many remaining shifts as possible.

Pre-conditions: A list of employees exists and contains employees.
The schedule contains shifts to be filled.
Post-conditions: A scheduled is generated where shifts contained matched employees.
Function Call : Optimize()

Parameters:
employeesList - NOTE: both Generate() and Optimize() are not efficient for a large number of employees because they grow exponentially with respect to the number of employees. However, this is ok for a stage one implementation. A more efficient algorithm is on the way.

Optimize

public void Optimize(ListOfEmployees employeesList)
The function Optimize is called in the Generate function. It does permutations between scheduled and not yet scheduled employees in order to fill the maximum number of shifts The first step in Optimize is to create a list of all the unscheduled employees
Parameters:
employeesList -  

AddShift

public void AddShift(int day,
                     Shifts toAdd)
Adds a shift to the schedule on a specific day

Pre-conditions: Valid variables of type int and Shifts are passed.
The passed int is a valid day of the week.
Post-conditions: The passed shift is added to the template for the passed day.

Parameters:
day - day to add shift to (i.e. 1=Monday,...)
toAdd - the shift to add to the specified day

RemoveShift

public void RemoveShift(int day,
                        Shifts toRemove)
Removes a shift from the schedule on a specific day

Pre-conditions: Valid variables of type int and Shifts are passed.
The passed int is a valid day of the week.
Post-conditions: If the passed shift exists on the schedule it is removed for the passed day.

Parameters:
day - day to remove a shift from (i.e. 1=Monday,...)
toRemove - the shift remove from the specified day

SetEmployee

public void SetEmployee(int day,
                        Shifts toSet,
                        Employees newEmployee)
Sets an employee to a shift on a specified day

Pre-conditions: Valid variables of type int, Shifts, and Employees are passed.
The passed int is a valid day of the week.
Post-conditions: The passed employee is set for the passed shift on the passed day.

Parameters:
day - day that contains the shift to set the employee to
toSet - the shift to set the employee to
newEmployee - the employee to assign to the shift

GetShifts

public java.util.Vector GetShifts(int day)
Gets all of the shifts on a particular day

Pre-conditions: A valid variable of type int is passed
and contains a valid day of the week.
Post-conditions: Returns a vector of shifts for the passed day.

Parameters:
day - day to get shifts from
Returns:
a vector of shifts assigned to that particular day