Class Shift

Shift

public class Shift

A Shift represents a duration of time during which an employee is scheduled to work. A shift is associated with a particular job skill which someone is required to have before they can work this shift. A shift can be filled by at most one employee.

Note to students: Suggested javadoc command options are:
-verbose -author -version -private -nohelp -nodeprecated -linksource -windowtitle

Version:
1.0 - June 07, 2001
Author:
John Dalbey

Constructor Summary
Shift(Time startTime, Time endTime)
          Construct a shift from starting and ending times.
 
Method Summary
 int durationOf()
          Determines how many hours are in this shift.
 Employee getEmployee()
          Gets the employee who is assigned to work this shift.
 Skill getSkill()
          Gets the skill associated with this shift.
 boolean isFilled()
          Return whether or not this shift has been assigned an employee.
 void setEmployee(Employee person)
          Assigns an employee to this shift.
 void setSkill(Skill aSkill)
          Associates a job skill with this shift.
 

Constructor Detail

Shift

public Shift(Time startTime,
             Time endTime)
Construct a shift from starting and ending times.
Parameters:
startTime - the time this shift starts
endtime - the time this shift ends
Method Detail

durationOf

public int durationOf()
Determines how many hours are in this shift.
Returns:
The number of hours in this shift, rounded up to the nearest integer.
Pre: endtime >= starttime

getEmployee

public Employee getEmployee()
Gets the employee who is assigned to work this shift.
Returns:
the employee who is assigned to work this shift

getSkill

public Skill getSkill()
Gets the skill associated with this shift.
Returns:
the skill associated with this shift

isFilled

public boolean isFilled()
Return whether or not this shift has been assigned an employee.
Returns:
true if this shift is filled, false otherwise.

setEmployee

public void setEmployee(Employee person)
                 throws WrongSkillException
Assigns an employee to this shift.
Parameters:
person - the employee who is to work during this shift
Pre: This shift has a skill associated with it.
Post: This shift is filled.
Throws:
WrongSkillException - if the employee doesn't have the skill needed for this shift.

setSkill

public void setSkill(Skill aSkill)
Associates a job skill with this shift.
Parameters:
aSkill - the skill that someone is required to have in order to work this shift.