2

In a UML class diagram, how would I model a tutor can work multiple days of the week without knowing specifically? In my current solution: 1 or more tutors work on 1 or more days of the week.

enter image description here

1
  • What's wrong with what you have? Looks understandable to me. The only thing I'd say is you have two classes for DaysOfTheWeek. You only need one, maybe draw the association from tutor to the enum with the list instead.
    – muszeo
    Commented Feb 21, 2018 at 5:02

1 Answer 1

2

Since the list of days when Tutor work is only an attribute and doesn't seem to have any specific structure to build a class around it, it should rather be an inline attribute with type DaysOfTheWeek and multiplicity 1..7 . Also since you can't work twice at the same day you should add unique constraint. Your argument (within the class Tutor ) should look like that:

         -workingDays : DaysOfTheWeek [1..7] {unique}

The multiplicity on Tutor side in your diagram suggests you have at least one Tutor for each possible working day (enumeration value). If this is true you can add this as a class constraint then. For traceability reasons you can add dependency (dashed line with open arrow) from Tutor to DaysOfTheWeek , but that's not necessary.

If you have a reason to build a dedicated class, your diagram can look like this

Class version diagram

I'm sorry, for some reason my tool doesn't export the stereotype even though I've placed it. DaysOfTheWeek should have the Enumeration but it was lost in the export.

A general side remark: a class has to have a name. It can't be just a stereotype.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.