You are on page 1of 3

Review Exercises

NAME _____________________

Chapter 12 Review Exercises

R12.1. What is the software life cycle?

R12.2. List the steps in the process of object-oriented design that this chapter recommends for student use.

R12.3. Give a rule of thumb for how to find classes when designing a program.

R12.4. Give a rule of thumb for how to find methods when designing a program.

R12.5. After discovering a method, why is it important to identify the object that is responsible for carrying out the action?

R12.6. What relationship is appropriate between the following classes: aggregation, inheritance, or neither? (a) (b) (c) (d) (e) (f) (g) (h) UniversityStudent StudentTeachingAssistant StudentFreshman StudentProfessor CarDoor TruckVehicle TrafficTrafficSign TrafficSignColor

R12.7. Every BMW is a vehicle. Should a class BMW inherit from the class Vehicle? BMW is a vehicle manufacturer. Does that mean that the class BMW should inherit from the class VehicleManufacturer?

Review Exercises

NAME _____________________

R12.8. Some books on object-oriented programming recommend using inheritance so that the class Circle extends the class Point. Then the Circle class inherits the setLocation method from the Point superclass. Explain why the setLocation method need not be redefined in the subclass. Why is it nevertheless not a good idea to have Circle inherit from Point? Conversely, would inheriting Point from Circle fulfill the is-a rule? Would it be a good idea?

R12.9. Write CRC cards for the Coin and CashRegister classes described in Section 8.2.

R12.10. Write CRC cards for the Bank and BankAccount classes in Section 7.2.

R12.11. Draw a UML diagram for the Coin and CashRegister classes described in Section 8.2.

R12.12. A file contains a set of records describing countries. Each record consists of the name of the country, its population, and its area. Suppose your task is to write a program that reads in such a file and prints The country with the largest area The country with the largest population The country with the largest population density (people per square kilometer) Think through the problems that you need to solve. What classes and methods will you need? Produce a set of CRC cards, a UML diagram, and a set of javadoc comments.

R12.13. Discover classes and methods for generating a student report card that lists all classes, grades, and the grade point average for a semester. Produce a set of CRC cards, a UML diagram, and a set of javadoc comments.

R12.14. Consider a quiz grading system that grades student responses to quizzes. A quiz consists of questions. There are different types of questions, including essay questions and multiple-choice questions. Students turn in submissions for quizzes, and the grading system grades them. Draw a UML diagram for classes Quiz, Question, EssayQuestion, MultipleChoiceQuestion,

Review Exercises Student, and Submission.

NAME _____________________

Copyright 2008 John Wiley & Sons, Inc. All rights reserved.

You might also like