2

I have the following situation/ model:

enter image description here

I have a Player class which has a Color and a Figure. Quite simple. But now I want to give the Figure an association to the Color:

enter image description here

Now I'm looking for a way to force the Figure to have the same Color as the Player. Perhaps I'm missing something very obvious, but I don't have any idea how to do it. Is there any OCL expression?

I'm using Magic Draw.

Thomas Uhrig
  • 30,811
  • 12
  • 60
  • 80

3 Answers3

4

You can use a ternary association. UML supports N-ary associations. See here.

Also, here is a YouTube video about drawing ternary associations in MagicDraw.

Mehdi Charife
  • 722
  • 1
  • 7
  • 22
Michalis Famelis
  • 198
  • 1
  • 11
2

Let Color be an associationClass between the others, so that for every two instances of them, there is a single instance of color, which is what you want.

Cairnarvon
  • 25,981
  • 9
  • 51
  • 65
1

"Figure to have the same Color as the Player"

This is, usually, not handled as a direct association, but, indirectly, by the Player class & its associations.

Its valid to have a "Color" property in "Figure", and add a restriction, that is modeled as a O.C.L. comment / note.

umlcat
  • 4,091
  • 3
  • 19
  • 29