Sams Teach Yourself C++ in 21 Days

(singke) #1
Object-Oriented Analysis and Design 363

11


~Car();
// other public methods elided
private:
PerformanceCharacteristics * pPerformance;
};
As a final note, powertypes enable you to create new types(not just instances) at run-
time. Because each logical type is differentiated only by the attributes of the associated
powertype, these attributes can be parameters to the powertype’s constructor. This means
that you can, at runtime, create new typesof cars on the fly. That is, by passing different
engine sizes and shift points to the powertype, you can effectively create new perfor-
mance characteristics. By assigning those characteristics to various cars, you can effec-
tively enlarge the set of types of cars at runtime.

Dynamic Model ..............................................................................................


In addition to modeling the relationships among the classes, it is critical to model how
they interact. For example, the CheckingAccount,ATM, and Receiptclasses can interact
with the Customerin fulfilling the “Withdraw Cash” use case. You now return to the
kinds of sequence diagrams first used in analysis, but now flesh out the details based on
the methods developed in the classes, as shown in Figure 11.21.

FIGURE11.21
Sequence diagram.


Customer AT M Checking Account

1: Check Balances

2: Get Balance

3: Display Balance

6: Print

4 : Withdraw cash

5 : Dispense

Receipt
Free download pdf