Uploaded by temeplate f

APCS Unit 9 Inheritance In-Depth Review - Ajay Gandecha 2

advertisement
Idea of
Inheritance
a
properties
Veggiesuperdass
A
subclass
Steam
class
inheriting
from another class
Superclass
subclass
is A relationship
specialized vehicle
Diesel
specialized trains
Hierarchy is created
Constructors are
Not
Superclass
Superclass
class Vehicle
inherited
Diesel
class Effaiih
class Train
name
string
name
string
name
string
make
string
make
string
make
string
Model
string
Model
string
Model
string
VehicleC
D
MoveForward C
Overriding
a
method
Train C
D
moveForwardC
Conductor string
Eiffel C
moveForward C
Conductor string
oillevel double
class Vehicle
11fields
public String name
public string make
public String model
11 constructor
Vehicle
public
1
implementation
public void
not
shown
move ForwardC
E
Il do something
class Train extends vehicle E
field
public String conductor
11 constructor
public
Train
I
1
implementation
public void
not
shown
move ForwardC
I
E
h
do something easy
Class DieselEngineTrain extends Train E
field
public double oil Level
11 constructor
publicDieselEngineTrain L
1
S
r
implementation
Garand
not
accesses
shown
the
I
superclass's
constructor
list of vehicles
List of Trains
Train
vehicle
X
Download