Creating a Composition

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

  1. Create a class named Claimant inside the claim package.
  2. Create attributes of name and address, both of type Text, within Claimant.
  3. Select the Composition tool (in the Relationships tool group on the palette).
  4. 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.

  5. 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.

  6. Select the 1 in the Multiplicity field.

    The lightbulb icon is displayed, indicating that content assistance is available.

  7. Type Ctrl+space to see a content assistance menu listing the possible values.
  8. 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.

  9. Create a class named Witness inside the claim package. Create name and address attributes as for Claimant.
  10. Connect Witness to Generic Claim using a composition exactly as described.
  11. 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.