How to reference and initialize a defined class?

0 votes
asked Jun 22, 2021 in Question / help by UMLG (120 points)

Hi,

I defined a Tree class as follows:

@startuml

class Tree {

  Depth: 0

  --

  MaxValue: 0

  --

  MinValue: 0

}

@enduml

Then I want to generate a new Tree class with initialized value like C/C++:

@startuml

Tree tree(10,5,6)

@enduml

So how to implement this?

1 Answer

0 votes
answered Jun 22, 2021 by The-Lu (64,760 points)

Hello U.,

Here is an example of procedure, as:

@startuml
!procedure $tree($d, $max, $min)
class "Tree" as tree-$d-$max-$min {
  Depth: $d
  --
  MaxValue: $max
  --
  MinValue: $min
}
!endprocedure

$tree(1,2,3)
$tree(10,5,6)
@enduml

If that can help,
Regards,
Th.

commented Jun 23, 2021 by UMLG (120 points)
Thanks a lot! I appreciate your help
...