OCL Assignment
Using the attached model of a company and its employees, please express the following requirements using OCL. Note: for some of these you will need to modify the class diagram; you may either modify the diagram directly and scan it in or you may specify in your answer textually how to modify the class diagram (e.g., for class: Project, add method X() , etc.). Finally, it is alright if you want to add a class or two to the diagram.
Express the following requirements using OCL:
1. Calculate the age of an employee.
2. The project leader is a project member.
3. All company employees must be over 18 years old.
4. The list of employees working in a department should always be sorted by last name.
5. Find the subset of employees who are older than 50.
6. Determine the number of employees the company has.
7. An employee's start date must be earlier than his/her last date (employment "to" date.) For current employees, the "to" date of employment is today's date.
8. All project members must be current employees.
9. Using OCL, define an operation to return the set of issued cards for a given department in a company.
10. Write ONE pre-condition and ONE post-condition for company.hire() that semantically fits using the other model elements.
11. Write one complex OCL expression using at least TWO levels of navigation AND write the natural language requirement represented by that OCL expression. You may add to the class diagram for this problem if you wish.