Search code examples
classattributesumldiagramcontract

Contract multiple similar attributes in UML


In school we should draw an UML class diagramm for a class we plan to write (we should do the planning).

I now have 10 JLabels, which are attributes to the class Game and each showing a different picture, but all off them serving the same purpose. To keep it a bit clearer, the Labels will be called Player1Throw1 to Player1Throw5 and Player2Throw1 to Player2Throw5.

My question is, if there is a correct way in UML to contract these 10 labels, so that I don't have to write

Game
--------
-Player1Throw1: JLabel
-Player1Throw2: JLabel
-Player1Throw3: JLabel
-Player1Throw4: JLabel
-Player1Throw5: JLabel
-Player2Throw1: JLabel
-Player2Throw2: JLabel
-Player2Throw3: JLabel
-Player2Throw4: JLabel
-Player2Throw5: JLabel

Or in other words: Is there a way to contract these 10 lines in maybe 2 lines?

Thanks for any help!


Solution

  • You could use the following notation in UML:

    - Player1Throw : JLabel[5]

    - Player2Throw : JLabel[5]