1

Let's consider the following class diagram

enter image description here

I would like to express the following rule in OCL

if cond = true then 
  bderived = b 
else
  bderived.x = b.x + 10
  bderived.y = b.y + 10
endif

My best guess to express the above using OCL is the following:

context A::bderived : B
derive: if cond = true then b
        else 
           {b.x + 10, b.y + 10}
        endif

I know that the above OCL expression is not correct, but I cannot figure out any valid OCL expression to express what I want.

Thomas Owens
  • 79,623
  • 18
  • 192
  • 283
Robbo
  • 167
  • 3

0 Answers0