Book a Demo

Author Topic: How do you set initial values for attributes of a class?  (Read 4005 times)

mse

  • EA User
  • **
  • Posts: 308
  • Karma: +1/-0
    • View Profile
How do you set initial values for attributes of a class?
« 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}
« Last Edit: May 21, 2021, 09:04:24 pm by mse »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How do you set initial vlaues for attributes of a class?
« Reply #1 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