Containment Often, one object is composed of many subobjects. For example, a car
is composed of a steering wheel, tires, doors, radio, and so forth. A checking account is
composed of a balance, a transaction history, a customer ID, and so on. The checking
account hasthese items; containment models the “has a”relationship. The UML illus-
trates the containment relationship by drawing a line with a diamond from the containing
object to the contained object, as shown in Figure 11.6.
342 Day 11
FIGURE11.6
Containment. Checking Account
Balance
Aggregation
The diagram in Figure 11.6 suggests that the Checking Account has aBalance. You can
combine these diagrams to show a fairly complex set of relationships (see Figure 11.7).
FIGURE11.7
Object relationships.
Bank Account
Checking Account Savings Account
Balance Transaction History