www.pudn.com > use-2.3.0.zip > Demo.use
-- $ProjectHeader: use 2-3-0-release.1 Mon, 12 Sep 2005 20:18:33 +0200 green $
model Company
-- classes
class Employee
attributes
name : String
salary : Integer
end
class Department
attributes
name : String
location : String
budget : Integer
end
class Project
attributes
name : String
budget : Integer
end
-- associations
association WorksIn between
Employee[*]
Department[1..*]
end
association WorksOn between
Employee[*]
Project[*]
end
association Controls between
Department[1]
Project[*]
end
-- OCL constraints
constraints
context Department
-- the number of employees working in a department must
-- be greater or equal to the number of projects
-- controlled by the department
inv MoreEmployeesThanProjects:
self.employee->size >= self.project->size
context Employee
-- employees get a higher salary when they work on
-- more projects
inv MoreProjectsHigherSalary:
Employee.allInstances->forAll(e1, e2 |
e1.project->size > e2.project->size
implies e1.salary > e2.salary)
context Project
-- the budget of a project must not exceed the
-- budget of the controlling department
inv BudgetWithinDepartmentBudget:
self.budget <= self.department.budget
-- employees working on a project must also work in the
-- controlling department
inv EmployeesInControllingDepartment:
self.department.employee->includesAll(self.employee)