Reputation: 35
An attribute of a class is an enumeration. How do i model this?
Normally you do something like this: - name : string
But how to do this with an enum? , what is the standard uml representation of enum ?
Upvotes: 0
Views: 347
Reputation: 1315
An enumeration
is a data type whose values are enumerated in the model as user-defined enumeration literals.
An enumeration
may be shown using the classifier notation (a rectangle) with the keyword «enumeration»
. The name of the enumeration is placed in the upper compartment. A compartment listing the attributes for the enumeration is placed below the name compartment. A compartment listing the operations for the enumeration is placed below the attribute compartment.
A list of enumeration literals may be placed, one to a line, in the bottom compartment. The attributes and operations compartments may be suppressed, and typically are suppressed if they would be empty.
Example
_____________________
| <<enumeration>> |
| DaysOfTheWeek |
|_____________________|
| Sunday |
| Monday |
| Tuesday |
| ... |
|_____________________|
Such an enumeration can be used as a datatype for attributes and parameters. So your attribute would be shown as
- Day : DaysOfTheWeek
Upvotes: 6