blake
blake

Reputation: 851

constructor with parameters in UML class diagram

How would you create an uml class diagram for constructors with parameters?

For default constructors (no parameters) you do

For constructors with parameters would you do the same thing:

It also asked to initialize each attribute to value where an object of this type can be instantiated. If a policy number is not between 1000 and 999 inclusive, then set the policy number to 0. (policy number is attribute)

Upvotes: 82

Views: 164236

Answers (1)

magnattic
magnattic

Reputation: 12998

The common way is to write constructors like methods and simply omit the return type.

enter image description here

If you want to be extra clear, you can add <<constructor>> in front.

Upvotes: 136

Related Questions