|
|
 |
|
|
|
|
ing the name of the country). The public operations of InterAddress are Write (which overrides the Write function inherited from Address) and a class constructor that receives five parameters (street, city, state, zip code, and country code). Write a class declaration for the InterAddress class. |
|
|
|
|
|
|
|
|
4. Implement the InterAddress class constructor. |
|
|
|
|
|
|
|
|
5. Implement the Write function of the InterAddress class. |
|
|
|
|
|
|
|
|
6. Write a global function PrintAddress that takes a single parameter and uses dynamic binding to print either a U.S. address or an international address. Make the necessary change(s) in the declaration of the Address class so that PrintAddress executes correctly. |
|
|
|
|
|
|
|
|
7. In Chapter 15, we developed a TimeType class (page 866) and a DateType class (page 872). Using composition, we want to create a TimeAndDay class that contains both a TimeType object and a DateType object. The public operations of the TimeAndDay class should be Set (with six parameters to set the time and day), Increment, Write, and a default constructor. Write a class declaration for the TimeAndDay class. |
|
|
|
|
|
|
|
|
8. Implement the TimeAndDay default constructor. |
|
|
|
|
|
|
|
|
9. Implement the Set function of the TimeAndDay class. |
|
|
|
|
|
|
|
|
10. Implement the Increment function of the TimeAndDay class. (Hint: If the time part is incremented to midnight, increment the date part.) |
|
|
|
|
|
|
|
|
11. Implement the Write function of the TimeAndDay class. |
|
|
|
|
|
|
|
|
1. Your parents are thinking of opening a video rental store. Because they are helping with your tuition, they ask you to write a program to handle their inventory. |
|
|
|
 |
|
|
|
|
What are the major objects in a rental store? The items to be rented and people who rent them. You begin with the abstraction of the items to be rentedvideo tapes. To determine the characteristics of a video object, you jot down a list of questions. |
|
|
|
 |
|
|
|
|
Should the object be one physical video, or should it be a title (to allow for multiple copies of a video)? |
|
|
|
 |
|
|
|
|
What information about each title should be kept? |
|
|
|
 |
|
|
|
|
Should the object contain a place for the card number of the person who has it rented? |
|
|
|
 |
|
|
|
|
If there are multiple copies, is it important to keep track of specific copies? |
|
|
|
 |
|
|
|
|
What operations should a video object be able to execute? |
|
|
|
 |
|
|
|
|
You decide that the basic object is the title, not an individual tape. The number of copies owned can be a data member of the object. Other data members should include the title, the movie stars, the producer, the director, and the production company. The system eventually must be able to track who has rented which videos, but this is not a property of the video object itself. You'll worry about how to represent the has rented object later. For now, who has which specific copy is not important. |
|
|
|
 |
|
|
|
|
The video object must have operations to initialize it and access the various data members. In addition, the object should adjust the number of copies (up or down), determine if a copy is available, check in a copy, and check out a copy. Because you will need to create a list of videos later, you decide to include operations that compare titles and print titles. |
|
|
|
|
|