Volume 5: Class & Object (OOP)
24 - Class Basics
About 'this' Add Methods to Class
25 - Inheritance 26- Drone Class in CodeCraft
Child Classes: Builder Drone, Eliminator Drone Bob (the Builder)
Classes and objects are the two main aspects of Object Oriented Programming (OOP).
We will talk about the most fundemental parts of OOP: defining a class, creating objects of the class, adding methods to customize objects, and inheritance.
We'll define a Drone class in CodeCraft. A Drone object can move up/down, right/left, forward/backward and can go to a location instantly. It can also show or hide itself on your command.
By applying inheritance, we then define two child classes: Builder(Drone) and Eliminator(Drone), they can build block or delete block. And last, we put these into application, to define 'Bob'(a function) utilizing Builder Drone. You can call Bob to move to places, blink to show itself, then put a block below it's location.
See a line structure design using Builder object (This is actually in motion, but to save space, we just put a still picture)
See 'Bob' in action: