Search code examples
umlclass-diagram

Class diagram count options and add options


I have a class diagram for a menu.

class diagram

How do I know how many menu options there are available (menu items), and how do I add more.

I was thinking since its 0..* it should be initially 0, but you could add up to an N amount.


Solution

  • The multiplicity 0..* tells you that an instance of a Menu can have between 0 and unlimited number of MenuItem.

    The class-diagram makes general statements about your classes. It does not tell anything about specific moments in time, chronology, nor behavior.

    The Menu constructor is not specified. We may suppose that a new Menu starts with no items. But we don't know for sure: there could well be a constructor to which one or several items are provided as argument right from the start.

    From its name, we can guess that the Menu operation AddItem() adds new items to a menu. From its arguments, we can guess that AddItem() construct those items to be added.

    Not related: the constructor MenuItem() should be preceded by «Create». But most readers would guess the meaning.