This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 15-100 HOMEWORK 10 - FALL 2007Answer the following questions on paper and hand in at the start of class on the due date indicated. 1. A set of objects are related to one another through inheritance. For example, the following shape classes are related as shown at right. For example, Squareis a subclass of Rectangle, since a square is a rectangle, but a rectangle is not necessarily a square. Rectangleis a subclass of Parallelogram, and Triangleand Parallelogramare both subclasses of Polygon, and so on. For the following list of objects, draw a diagram similar to the diagram above that indicates the class hierarchy of these objects with respect to one another using the principle of inheritance. (Each class should have no more than one superclass.) Boat, Car, Cement Mixer, Glider, Hearse, Jet, Limousine, Plane, Policecar, Sedan, Ship, Supertanker, Trimaran, Truck, Vehicle, Yacht 2. Let Timebe a class that represents a length of time in hours and minutes. (Minutes is an integer between 0 and 59, and hours is a non-negative integer.) The amount of total minutes integer between 0 and 59, and hours is a non-negative integer....
View Full Document
This note was uploaded on 01/25/2010 for the course CS 15100 taught by Professor Tom during the Fall '07 term at Carnegie Mellon.
- Fall '07