Beispiel #1
0
  public boolean addShift(Shift aShift) {
    boolean wasAdded = false;
    if (shifts.contains(aShift)) {
      return false;
    }
    if (shifts.contains(aShift)) {
      return false;
    }
    if (shifts.contains(aShift)) {
      return false;
    }
    Employee existingEmployee = aShift.getEmployee();
    boolean isNewEmployee = existingEmployee != null && !this.equals(existingEmployee);

    if (isNewEmployee && existingEmployee.numberOfShifts() <= minimumNumberOfShifts()) {
      return wasAdded;
    }
    if (isNewEmployee) {
      aShift.setEmployee(this);
    } else {
      shifts.add(aShift);
    }
    wasAdded = true;
    return wasAdded;
  }
Beispiel #2
0
  public boolean removeShift(Shift aShift) {
    boolean wasRemoved = false;
    // Unable to remove aShift, as it must always have a employee
    if (this.equals(aShift.getEmployee())) {
      return wasRemoved;
    }

    // employee already at minimum (1)
    if (numberOfShifts() <= minimumNumberOfShifts()) {
      return wasRemoved;
    }

    shifts.remove(aShift);
    wasRemoved = true;
    return wasRemoved;
  }