Inheritance: Wizard Spell Academy
Help a Wizard use one power borrowed from a parent class and one power of its own.
A child class does not have to rewrite everything. It can inherit a shared method from its parent, then add a new method of its own.
chargeMagic()Child: inherits itChild adds: castSpell()When different objects share the basics but need special powers.
Imagine a game with a Wizard, Healer, and Sorcerer. They all need a name, magic energy, and chargeMagic(). Put those shared features in MagicCharacter once. Then each child class adds only what makes it different.
inherits chargeMagic()adds castSpell()inherits chargeMagic()adds healTeam()inherits chargeMagic()adds summonStorm()Rule of thumb: If you are copying the same properties or methods into several similar classes, a parent class may help.
Select Wizard extends MagicCharacter.
Run inherited chargeMagic().
Run child-only castSpell().
MagicCharacterchargeMagic()Find the child that extends this parentStart here: Which character extends MagicCharacter?
Step 1: Select the Wizard.



The Wizard has no active magic yet.
See the JavaScript connection
class Wizard extends MagicCharacterInheritance lets Wizard reuse the parent’s chargeMagic() method.
Wizard inherited chargeMagic() and used its own castSpell().
