2

enter image description hereSo I need to practice UML for a uni course and I can't figure out the following:

We need to make a UML Class diagram of a sports association. There is a player table. A sub-class of the player table is the referee table. A player is part of a team, and so is a referee (since referees are players also). A referee gets assigned to a match, but it can't be the match of his own team.

I can't find the answer to the last sentence. How do I put this in the UML Class diagram?

UML diagram is in Dutch. Wedstrijd = match, scheidsrechter = referee the others are not really necessary.

Christophe
  • 68,716
  • 7
  • 72
  • 138
FanaTiek
  • 23
  • 3
  • 2
    You'll at least have to show how far you got, and where exactly you are stuck. You can update your question with more details and the image of your current UML diagram. – Geert Bellekens Feb 20 '23 at 09:51
  • 1
    Your description of the question doesnt match your diagram. A referee is not a subclass of player, but a subclass of member (Leden). Since the most common interpretation is that a object cannot be an instance of two classes at the same time, this means a player cannot be a referee. Also, you should review all of your compositions and multiplicities. They don't make sense for the most part. – Geert Bellekens Feb 21 '23 at 13:31
  • I edited the title to allow people to find this question if they face similar problems. Don't hesitate to change it if it doesn't describe sufficiently well the core of the problem – Christophe Feb 22 '23 at 19:15

2 Answers2

2

Your diagram has probably a couple of problems, because it says that for a competition (Wedstrijd) there's only one Team (composte aggregation) , which sounds neither competitive nor entertaining. Moreover it says that a club (Sportsverijn) has at maximum one member, which doesn't fit with the narrative.

Once these problems solved (and a couple of others), and supposing that a Wedstrijd involves two teams, you may add constraints to your model to express these complex conditions.

Typically, you would express them between curly braces, in plaintext: { cannot be referee for a match involving the relevant team } next to the association between the match (Wedstrijd) and the referee (Scheidsrechter). This natural language constraint is ambiguous. A more formal expression could be written in OCL, something like: match.team->includes(match.referee.team) == false

The details of the expression will of course depend whether your model is a snapshot (seems to be the case here), or if it takes into account the fact that referees may change team in time. Here I have an alternative model that avoids composite aggregation and that associates referees to teams, with two examples of constraints:

enter image description here

Christophe
  • 68,716
  • 7
  • 72
  • 138
0

While the answer of @Christophe is perfect, I found a way to express the same without constraints: enter image description here Of course, it makes use of some not so wellknown constructs: Generalization between associations, composite structure diagrams and private behavior ports. However, I believe it is useful, since it not only covers the fact, that the referee must be from a different team, but also, that only 11 players can be activly involved in the match at a given time.

Axel Scheithauer
  • 2,758
  • 5
  • 13