Multiplicities and roles in class diagrams

+1 vote
asked Oct 24, 2018 in To be sorted by anonymous
Hello,

I tried to have a role and a multiplicity on an association, For Example:

class Example "1 example" -right- "example2 *" class Example2

This works, but I want the 1 on top of the line, example below the line. Is this possible somehow?
commented Oct 24, 2018 by albert (3,520 points)
I tried the example in the plantuml webserver http://www.plantuml.com/plantuml/uml but it fails. Did you have a look at the examples: http://plantuml.com/class-diagram ?

1 Answer

0 votes
answered Oct 25, 2018 by mgrol (3,150 points)

Hi, 

what you do is the definition of the classes and the linking in one step. What you need to do is to separate these

like this:

@startuml
class Example
class Example2
Example "1" -right- "*" Example2 : description
@enduml

or to remove the class keyword and let plantuml do the initialization of the classes like this.

@startuml
Example "1" -right- "*" Example2 : description
@enduml

Both result in :

BR,

Michael

commented Oct 25, 2018 by albert (3,520 points)
On important thing to not is that when not specifying "right" the "1" and "*' are on the left side and the word description is on the left side, with the word right all is above the line. From the question I gather that OP ants to have the word description below the line and the "1" and "*" above (or vice versa). See plantuml webrowser: http://www.plantuml.com/plantuml/png/SoWkIImgAStDuKhEIImkLd2jICmjo4b5vHbnGHaAIePA2hf5cUaP9ReAIbfAS0KALWefgSN9HPa59PdvULoeserHkIOmqmmXng6OP89caaDgNWhGTG00
...