/
Inheritance CSCE  121  Recall Inheritance CSCE  121  Recall

Inheritance CSCE 121 Recall - PowerPoint Presentation

Honeybunches
Honeybunches . @Honeybunches
Follow
342 views
Uploaded On 2022-08-03

Inheritance CSCE 121 Recall - PPT Presentation

Classes can model things that can be concrete or abstract Truck Weight Fuel type Length Height Drive Stop Etc Fire Truck Truck Weight Fuel type Length Height Drive Stop WaterCapacity ID: 934625

stop truck weight fire truck stop fire weight fuel stopsiren concrete startsiren type length height drive members watercapacity typelengthheightdrive

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Inheritance CSCE 121 Recall" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Inheritance

CSCE

121

Slide2

Recall

Classes can model things that can

be concrete or abstract.

TruckWeightFuel typeLengthHeightDrive()Stop()Etc.

Slide3

Fire Truck

Truck

Weight

Fuel typeLengthHeightDrive()Stop()WaterCapacitystartSiren

()

stopSiren

()

Add to truck class?

Slide4

Concrete Truck

Truck

Weight

Fuel typeLengthHeightDrive()Stop()WaterCapacitystartSiren

()

stopSiren

()

cubicFeetConcrete

Pour()

So every truck could “

startSiren

()”???

So we include members for all types of trucks?

Add to truck class?

Slide5

Separate Classes?

Truck

Weight

Fuel typeLengthHeightDrive()Stop()

Fire Truck

Weight

Fuel type

Length

Height

Drive()

Stop()

WaterCapacity

startSiren

()

stopSiren

()

Concrete Truck

Weight

Fuel type

Length

Height

Drive()Stop()cubicFeetConcretePour()

And more…

Slide6

Separate Classes?

Truck

Weight

Fuel type

Length

Height

Width

Drive()Stop()

Fire Truck

Weight

Fuel type

Length

Height

Drive()

Stop()

WaterCapacity

startSiren

()

stopSiren

()

Concrete Truck

WeightFuel typeLengthHeightDrive()Stop()cubicFeetConcrete

Pour()

How many updates???

Share what’s

common?

Slide7

Truck

Weight

Fuel type

LengthHeightWidthDrive()Stop()Separate Classes!

Fire Truck

WaterCapacity

startSiren

()

stopSiren

()

Concrete Truck

cubicFeetConcrete

Pour()

Share what’s

common!

Slide8

Truck

Weight

Fuel type

LengthHeightWidthDrive()Stop()Inheritance

Fire Truck

WaterCapacity

startSiren

()

stopSiren

()

Concrete Truck

cubicFeetConcrete

Pour()

Add to an existing class!

REUSE!!!

Truck

AND

Fire Truck

Truck

AND

Concrete Truck

Slide9

Some Terminology

Base / Parent

Derived / Child / Sub-Class

Slide10

Access Permissions

Public

Private

Protected

10

Public members

Protected members

Private members

All code

Derived class’s members

Class’s own members

Slide11

UML Updates for Inheritance

Permissions

+ Public

- Private# Protected

Slide12

UML Updates for Inheritance

Relations

Association

AggregationCompositionInheritanceNavigability

concept of easy access from one to another

Many

One

Base / Parent

Derived / Child

Access to

Access from

Composite Object

Part of

Slide13

Truck UML Class Diagram

Truck

-weight

#

fuelType

-length

-height

-width

+drive()

+stop()

Fire Truck

-

waterCapacity

+

startSiren

()+stopSiren

()

Concrete Truck

-

cubicFeetConcrete

+pour()

Slide14

Instance of a Fire Truck, i.e. Fire Truck Object

Truck

-weight

#

fuelType

-length

-height

-width

+drive()

+stop()

Fire Truck

-

waterCapacity

+

startSiren

()+stopSiren

()

It is both

a Truck

AND

a Fire Truck!