farha
farha

Reputation: 360

Class diagram: How to show a user can assign role to another user?

Lets say I have User and Role classes in my UML class diagram. User has one to many relationship with Role class

Attributes of User class: username, password, email

Attributes of Role class: roleType

enter image description here According to problem specification, a user can invite another user and assign roles. How can I show this relationship in class diagram?

Upvotes: 1

Views: 1973

Answers (1)

qwerty_so
qwerty_so

Reputation: 36305

Well, either you make the Role a public attribute of User

enter image description here

or you add an operation

enter image description here

(and probably a couple more of that) to assign (and eventually remove) Roles. Here I made role a protected attribute. Feel free to make it private and add query operations at your wish.

Upvotes: 0

Related Questions