First correction (recommended):
First, UML is not Java. The relation between Book
, Sword
or Stuff
classes on one side and Item
class on the other is shown with a generalization, and there's no need to label the arrow with Extends
. There's no confusion possible in this UML diagram with a realization relation (i.e. "implements"), since the latter would be shown with a dotted line.
Second correction (required):
Your narrative is inconsistend with your diagram. You mention in your question a Character
that can be a Monk
or a Palladin
, but your diagram suggest that a Palladin
in a kind of Monk
(According to the generalization relation that you display, Monk
would be the more general concept, and Palladin
would be a more specialized kind of Monk). This is confusing.
Starting point
So your starting diagram could look like:
Relationship you want to show:
You want to show that a Character
can have at any time only one Item
. So in practice, this means that you have a relation between a Character
and zero or one (0..1
) Items
that can be read as "owns" (the character owns an item). Conversely, an Item
can be owned by zero or one Character
.
This would be shown as follows:
Unfortunately, this would let any character own any kind of items. If you want to restrict this, you need to use an UML constraint. This is done by using a comment box and put a constraint between curly brackets {...}
. The formal way to do would be to use OCL language. But a more practical approach is to document the contraint in plain letters:
Here, the contraint is shown on the association. It's practical, since you could add other constraints for other kind of characters. However, you could also opt to show the constraint for the Monk
class instead (and other classes that have their associations constrained).