|
|
|
|
|
|
|
8. Define the following terms associated with object-oriented design: |
|
|
|
 |
|
|
|
|
problem domain |
|
|
|
 |
|
|
|
|
solution domain |
|
|
|
 |
|
|
|
|
implementation-level object |
|
|
|
|
|
|
|
|
9. Mark each of the following statements as True or False. |
|
|
|
 |
|
|
|
|
a. Every noun and noun phrase in a problem definition becomes an object in the solution domain. |
|
|
|
 |
|
|
|
|
b. For a given problem, there are usually more objects in the solution domain than in the problem domain. |
|
|
|
 |
|
|
|
|
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? |
|
|
|
 |
|
|
|
|
a. Object-oriented design |
|
|
|
 |
|
|
|
|
b. Structured (top-down) design |
|
|
|
|
|
|
|
|
11. Fill in each blank below with either is-a or has-a. |
|
|
|
 |
|
|
|
|
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 |
|
|
|
|
|
|
|
|
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;
}; |
|
|
|
 |
|
|
|
|
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- |
|
|
|
|
|