2

Chapter 1 Progress-Checks


1. Draw an object diagram for a Person class and two Person objects Ms. Latte and Mr. Espresso.


2. What must be defined before you can create an object?


3. Draw an object diagram of an Account object with instance methods deposit and withdraw.


4. Which message do you send to a class to create an instance of the class?


5. What is the difference between a constant and a variable?


6. Draw an object diagram of a Person object with three instance variables name, age, and gender.


7. Draw an object diagram of a Vehicle class and three Vehicle objects named car1, car2, car3.


8. Draw an object diagram of a Person class with the following components:


9. If we have Animal, Insect, and Mammal classes, which one will be a superclass? (Hint: draw the object diagram)


10. Suppose the Vehicle class in exercise 1 is used in a program that keeps track of vehicle registration for the Department of Motor Vehicles. What kinds of instance variables would you define for such Vehicle objects? Can you think of any useful class variables for the Vehicle class?


11. Define two new classes Car and Truck as subclasses of Vehicle. Hint: Associate class and instance variables common to both Car and Truck to Vehicle.

There are formulas for the annual vehicle registration fee for the vehicle registration program.


12. Imagine you are given a task of designing an airline reservation system that keeps track of flights for a commuter airline. List the classes you think would be necessary for designing such a system. Describe the data values and methods you would associate with each class you identify.

Hint: use the classes Airplane, flight, and seat.


13. Consider a program that maintains an address book. Design an inheritance hierarchy for the classes such as Relative, Staff, Personal, Person, Professional, Friend, MedicalDental, and Colleague.


14. Why is the design phase more important than the coding phase?


15. How does the quality of design affect the total cost of developing and maintaining software?