Yes. A fleet of cars consists of several cars.
Consider a fleet consisting of two cars: a town car and a sports utility vehicle. Think of the fleet as a single object composed of two objects. Remember that an object has (i) identity, (ii) state, and (iii) behavior. Is this true for a fleet of cars?
Here is a skeleton of the Fleet
class,
along with the definition of Car
and a testing class:
class Fleet { // data Car town; // the town car of the fleet Car suv; // the sports utility vehicle of the fleet // constructor // method } class Car // unchanged from above { . . . } class FleetTester { Fleet myCars; . . . }
The definition of class Car
is the same as above.
It does not change, even though Car
objects are now
used as part of a larger object.
The (not yet finished) definition of Fleet
says that a fleet consists of two cars.
Does the definition of class Fleet
include the definition of class Car
?