Search code examples
umlmodelingclass-diagram

Displaying a selection from a list in a class diagram


I'm making a diagram that shows the following:

Every day the student makes an order in the cafeteria, they can choose the full menu for today (for example, soup, sandwich, dessert, drink), as well as only some dishes from the menu (for example, only soup).

How to display this on a class diagram. Here my diagram. Should there be a relationship between the order and the menu or the order and the dishes?

my diagram


Solution

  • Should there be a relationship between the order and the menu or the order and the dishes?

    If you only have a relation between Order and Menu you have no way to know which dishes the student does not want, so if you have that relation you also need an other relation to indicate the (un)wanted Meal, but having that additional relation makes the relation between Order and Menu useless.

    So have a relation between Order and Meal, but no (direct) relation between Order and Menu.


    Out of that :

    • Is ordersType useful ? Also to have a composition to it has no sense because enum items always exist

    • A Menu is in relation with several Meal so the corresponding multiplicity must be 1..*

    • A Pupil can have several Order (multiplicity '*') so it seems several instances of Menu can exist at the same time, then a Meal can be part of several Menu so the corresponding multiplicity must be 1..* too.

    • The price of a Meal is an int, seems strange

    • The date of a Menu/Order is a double, seems strange too

    • The numClass of a Pupil is a string, strange if num means number