Superclass and Subclass Hierarchy
Given a list of attributes and behaviors for two classes:
- identify common attributes and behaviors that could be part of a superclass when creating a class hierarchy.
- list the remaining attributes and behaviors for the subclasses.
- name the superclass.
- write is-a statements for each class with the superclass.
- evaluate your is-a statements. Do they accurately represent the relationship? For example, "Student is-a Person"
Cars and Trucks
| Car | Truck | Superclass: Give it a name |
|---|---|---|
| Attributes | ||
| String brand | String brand | |
| String color | String color | |
| int year | int year | |
| int numberOfDoors | double cargoCapacity | |
| boolean hasSunroof | boolean hasFourWheelDrive | |
| Behaviors | ||
| start() | start() | |
| stop() | stop() | |
| displayInfo() | displayInfo() | |
| turnOnAirConditioning() | turnOnAirConditioning() | |
| openTrunk() | loadCargo() | |
| unLoadCargo() | ||
