Enumeration and Inheritance

posted in: Research Paper | 0

Enum is a command that allows us to create an array a values using strings instead of remembering the numeric values they hold. This is good for situations where you may have a finite set of options to offer the programmer or player.

Inheritance is the ability of one class to pass on its properties (vars) and abilities (methods/functions) to one child or a series of children. This is done to perpetuate evolution or a series of different options based on the Base (parent).

This week, you are going to create an enumeration for a series of possible weapons:
Bow, Wand, Sword, Staff

You will also use inheritance to create four new types of players with different stats and weapon options:
Archer, Wizard, Knight, Cleric (Weapons should be associated automatically with their player types, but it is possible for players of any type to find and collect/use other weapon types.)

 

Last Updated on