Skip Top Navigation Bar

Superclass and Subclass Hierarchy

Grab a Piece of Paper!

Given a list of attributes and behaviors for two classes:

  1. identify common attributes and behaviors that could be part of a superclass when creating a class hierarchy.
  2. list the remaining attributes and behaviors for the subclasses.
  3. name the superclass.
  4. write is-a statements for each class with the superclass.
  5. 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()

Teacher and Custodian

Teacher Custodian Superclass: Give it a name
Attributes
String name String name
int employeeId int employeeId
double hourlyRate double hourlyRate
String subject String assignedArea
int roomNumber boolean hasMasterKeys
Behaviors
clockIn() clockIn()
clockOut() clockOut()
displayEmployeeInfo() displayEmployeeInfo()
teachLesson() cleanArea()
gradeAssignments() lockBuilding()