Lesson 10

image

Inheritance: This code syntax shows how to create a new Child class that inherits from a parents class. All the methods and attributes can now be used in the new child class.

image

The extends keyword shows that the new PainterPlus class inherits from the original Painter class. This means that it inherits all of its properties and methods, and that these methods can be used in the new class.

PainterPlus.java

image

MyNeighborhood.java

image

Methods

Lesson 14

PainterPlus.java

image PainterPlus extends everything from the Painter parent class.

PatternPainter.java

image PatternPainter inherits from the PainterPlus class. Since PainterPlus inherits from Painter, PatternPainter will be able to use both PainterPlus and Painter methods and attributes.

BackgroundPainter.java

image BackgroundPainter goes even further and extends from PatternPainter, meaning it can use methods from PatternPainter as well as PainterPlus and Painter.

Check For Understanding

image

Taco extending food is the only one that represents a class inheritance example because Taco is a subclass of Food.