< previous page page_964 next page >

Page 964
8. Define the following terms associated with object-oriented design:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
problem domain
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
solution domain
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
implementation-level object
9. Mark each of the following statements as True or False.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. Every noun and noun phrase in a problem definition becomes an object in the solution domain.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b. For a given problem, there are usually more objects in the solution domain than in the problem domain.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
c. In the three-step process for performing object-oriented design, all decisions made during each step are final.
10. For each of the following design methodologies, at what general time (beginning, middle, end) is the driverthe top-level algorithmdesigned?
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. Object-oriented design
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b. Structured (top-down) design
11. Fill in each blank below with either is-a or has-a.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
In general, the best strategy in object-oriented design is to use inheritance for ______ relationships and composition for ______ relationships.
Programing Warm-Up Exercises
1. For the Line class of Quick Check Question 7, implement the StartingPoint and EndingPoint member functions.
2. For the Line class of Quick Check Question 7, implement the Length member function. Hint: The distance between two points (x1, y1) and (x2, y2) is
0964-01.gif
3. The following class represents a person's mailing address in the United States.
typedef char String20[21];

class Address
{
public:
    void Write() const;
    Address( /* in */ const String20 newStreet,
             /* in */ const String20 newCity,
             /* in */ const String20 newState,
             /* in */ const String20 newZip    );
private:
    String20 street;
    String20 city;
    String20 state;
    String20 zipCode;
};
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Using inheritance, we want to derive an international address class, InterAddress, from the Address class. For this exercise, an international address has all the attributes of a U.S. address plus a country code (a string indicat-

 
< previous page page_964 next page >