Periodically, a company processes the retirement of some of its employees. In this question, you will write methods to help the company determine whether an employee is eligible to retire and to process the retirement of employees who wish to retire. You will also analyze the runtime performance of one of the methods that you write.
The Java interface
Employee is implemented by
objects that represent employees. The interface is declared
Company class is declared as follows.
Two class invariants must be maintained by
myEmployees is sorted
(e.g., by employee ID), note that interface
myTotalSalary is the total
of all employee salaries.
Company constructor will establish these invariants as
true initially. Each
Company method must ensure that the
invariants remain true after the method's execution.
Write the private
employeeIsEligible, which is described as follows.
employeeIsEligible returns a boolean value
that indicates whether the employee represented by parameter
emp is eligible for retirement, using the rules above.
which is described as follows. Method
has one parameter,
claimants representing all employees
that wish to retire. Assume
claimants is sorted in
ascending order, contains no duplicates, and that all
claimants are also in private instance variable
myEmployees only those employees listed in
claimants that are eligible for retirement and maintains
the two class invariants described above: the ArrayList is maintained in
ascending order and
myTotalSalary is the total of all
salaries of the remaining employees.
Assume that the class used to implement the
interface has an overridden method
with its method
processRetirements, you may call
employeeIsEligible, specified in part (a). Assume
employeeIsEligible works as specified, regardless of
what you wrote in part (a).
processRetirements. Justify your answer with reference to the code you wrote in part (b). You will NOT receive full credit if you do not provide a justification.