A composition connects two classes, and it indicates that one of the two classes contains the other.
In this task you create a new class that is related by
composition
to your existing class.
Procedure
Create a class named
Claimant inside the
claim package.
Create attributes of
name and
address, both of type
Text, within
Claimant.
Select the
Composition tool (in the
Relationships tool group on the palette).
Click on
GenericClaim and drag the pointer to
Claimant.
This creates the composition.
The
General tab of the Properties view indicates the direction of the Composition.
Each claim must have at least one claimant, but could have more than one.
To specify possible number of claimants, select the multiplicity attribute (the figure
1) at the
claimant end of the composition.
The Properties view for the attribute is displayed.
Select the
1 in the
Multiplicity field.
The lightbulb icon is displayed, indicating that content assistance is available.
Type
Ctrl+space to see a content assistance menu listing the possible values.
Select, or type,
1..* to replace the multiplicity value. This indicates that there must be at least one claimant, but can be more.
The following steps create another class, also with composition but with different multiplicity.
Create a class named
Witness inside the
claim package. Create
name and
address attributes as for
Claimant.
Connect
Witness to
Generic Claim using a composition exactly as described.
Not all claims have witnesses. Therefore, specify the multiplicity attribute at the
witness end of the composition as
*. This means there can be zero or more witnesses—any number.