Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Latest commit

 

History

History
33 lines (22 loc) · 1.23 KB

inheritance.md

File metadata and controls

33 lines (22 loc) · 1.23 KB

Inheritance

The Concept

Defining classes as a hierarchy, with a specific class (Dog) inheriting the behavior and data of its more generic parent (Animal).

What to cover

  • What is inheritance? Why use inheritance?
  • How to use inheritance. What is the syntax to inherit from a class? How to override methods, etc.
  • Are there limitations to inheritance? Is there multi-inheritance or only single-inheritance?

Exercises

Role-playing game

This exercise models a role-playing game with wizards and warriors that can attack each other. The reference implementation (C#) teaches:

  • Defining an abstract class
  • Defining classes that inherit from an abstract class
  • Overriding abstract methods
  • Overriding virtual methods
  • Calling the base class' constructor from a derived class
  • Restrict access to inheriting classes using access modifiers

Implementations

Track Exercise Changes
C# wizards-and-warriors None