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 
  bderived.x = b.x + 10
  bderived.y = b.y + 10

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

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.