

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 8
click for more info
Not enough gems
Cost: 6 gems
1: Inheritance
incomplete
2: When to Inherit
incomplete
3: Inheritance Hierarchy
incomplete
4: Inheritance Quiz
incomplete
5: Multiple Children
incomplete
6: Adding a Wizard
incomplete
7: Wide Not Deep
incomplete
8: Dragons
incomplete
9: Dragons Fight
incomplete
10: Inheritance Practice
incomplete
11: Inheritance Practice
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
There is no (technical) limit to how deeply we can nest an inheritance tree. For example:
Tiger inherits from Feline inherits from Animal inherits from LivingThing.
That said, be careful! New programmers often get carried away. You should never think to yourself:
"Well most wizards are elves... so I'll just have
Wizardinherit fromElf"
A good child class is a more specific type of its parent class.
Let's add a new game unit: Crossbowman. A crossbowman is always an archer, but not all archers are crossbowmen. Crossbowmen have several arrows, but they have an additional method: triple_shot().
3 arrowstarget Human using its methodsTARGET was shot by 3 crossbow bolts where TARGET is the name of the Human that was shot