UML&OCL Modeling Languages


OCL Constraints: illustration

  1. As an exercise, represent the class diagram for persons having an age and children/parent then express the following constraints:

As a preleminary exercise, you can install and try USE tool that proposes an OCL interpreter.

  1. Constraints on operations are expressed by pre-post conditions illustrated below:
context Person::birthday()
pre: 
post: age' = age+1

The prime' represents the value of the attribute after execution.

As an exercise, how to define the addChildren(p) ?


4 - 9