Skip to content

Latest commit

 

History

History
7 lines (5 loc) · 407 Bytes

File metadata and controls

7 lines (5 loc) · 407 Bytes

Inheritance

  • when you have a child class that gets basic behavior from parent class
  • used to avoid rewriting common functions in every class that share similar behavior

In this example, we have two types on enemies (Ninja and Zombie). Since all enemies share certain behaviors (moving left and right) we can write all of the common functionality inside one parent class instead of every enemy class.