Volume 5: Class & Object (OOP)

Contents

24 - Simple Class & Objects

Add Methods to Class About 'self'

25 - Customizing Objects

__init__() method Flexible initialization More on 'self' __str__() method

26 - Inheritance 27- 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 fundamental 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.

Two examples:

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:

===

I can say this is the best and only program available now to teach OOP concepts in 3D visual. help to understand how the variables and methods are defined in the class and their behavior in class instances.

The 3D visual and intuitive results make it possible for Self taught programmers, beginners, young students to understand these abstract topics with ease.

results matching ""

    No results matching ""