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.

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.