As an OOP, you can use inheritance in your projects. This provides easy coding for you. For example, if you will create some of characters in your project, you can create a character class and use it for all different characters.

Lets create a character class.

This class includes a character type and a function named Shout. Now create a Soldier class.

This script uses the public specifications of Character class with inheritance. Lets use these two scripts in another.

This script creates new character of Character and soldier of Soldier. We set a new type of soldier.

©Coffee Break Codes – Inheritance

Leave a comment

Your email address will not be published. Required fields are marked *