CS 2010 Lab 13 Instructor Plan
A vehicle is either a car or truck. All vehicles have a make (e.g., "Ford"). Trucks carry things (and have a single driver), while and cars contain some number of people.
- Create the Vehicle abstract class, the Car class, and the Truck class. Include a getMake method in Vehicle and a getPersonCount method (which always returns 1 for trucks).
- Make lists of vehicles.
- Add a list method for summing the people in the vehicles.
- All Ford vehicles have a model number. Derive subclasses of Car and Truck for Ford cars and trucks. Include a modelNumber method in the new classes.
- Add a list method for filtering for a specific make.
- Add a list method for checking whether a model number is present, assuming that the list has been filtered into include only Ford makes. (With respect to filtering, assume that the vehicle's make will be reported as "Ford" only when it is an instance of the Ford car or truck class.) You'll need a Ford interface, and the method will have to use casts.
Last update: Wednesday, November 19th, 2003mflatt@cs.utah.edu |