Assignment 1 -- PTT13

Starting point

Either of these contributions:

You are well advised to simply download the entire repo 101simplejava:

You are also advised to follow this simple guide, as discussed in lecture and lab:


Revise your chosen contribution to meet the following requirements:

  1. Departments and employees (i.e., "subunits") have a getter for the parent, i.e., for the enclosing company or department.
  2. setSalary of Employee rejects a salary that is greater than the manager's salary of its parent department, if any.


Clearly you need to make sure that the "parent" is automatically set as companies are constructed. You may need to refactor the overall object model so that you can manage the parent as such. You could use some design patterns to streamline your solution. Here are some patterns that come to mind: "Observer", "Factory Method", or "Abstract Factory". Regardless, of whether and which design patterns are used, your design needs to be reasonably clear in addition to just passing tests. Make good use of static typing.


Your test cases need to exercise these behaviors:

  1. An employee is constructed and added to a specific department. As a result, the parent is just that department.
  2. A department is removed from the subunits of a department. As a result, the parent becomes undefined.
  3. setSalary indeed accepts valid values and rejects invalid values, in the view of the 2nd requirement above.