Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: mse on May 21, 2021, 06:41:59 pm

Title: How do you set initial values for attributes of a class?
Post by: mse on May 21, 2021, 06:41:59 pm
Suppose you have a class with an attribute typed by a class containing several attributes. How do you set the initial values? For simple types like integer, you just set Initial Value and you will see it show up in the class diagram as attribute = 0 but what about more complex types?

Class A
-timeStamp: Time

Class Time
-hours: int
-minutes: int
-seconds: int

I would like something like:

Class A
-timeStamp: {hours=1,minutes=20,seconds=24}
Title: Re: How do you set initial vlaues for attributes of a class?
Post by: Geert Bellekens on May 21, 2021, 07:47:07 pm
I don't think there's anything stopping you from writing that.

You could also do something like

timeStamp = new Time("01:20:24")

If your Time datatype has a constructor that takes a string.

Geert