Lesson Module · Detail

Own Classes (The Mini-Linus)

They introduce the class concept as a blueprint and link method definitions to concrete actions of an instance. Didactically, modeling behavior (methods) and their systematic application in a navigation-oriented task are in the center.

Time 10 minutes
Format rpgDungeon
Language Python 2 (CE)
Tasks 1
Preview Image: Own Classes (The Mini-Linus)

Introduction (Original excerpt)

In this level, you control Robot, the small robot from Professor Pixel. So far, you only know Functions. Now you learn something new: Classes.

Didactic classification

Subjective goal setting

The building block introduces the concept of a class as a blueprint and makes it visible how an abstract model (class) is transformed into a usable object (instance). The focus is on structuring behavior through methods that encapsulate specific movement directions. Learners work with a helper method for turning and derive further methods systematically from it. The connection between model and implementation is operationalized by direct method calls at an instance (e.g. robot). This makes it clear how design ideas (robot capabilities) are converted into concrete, reusable program interfaces.

Competence development

Didactic added value in the classroom

Flow of the lesson unit

1

Assemble the robot

They allow a class to be extended specifically by adding missing methods. The step serves the practice of method definition, reuse of a helper method, and subsequent application through method calls at an instance in the overall process of navigation.

  • Didactic focus: Abstraction through methods and consistent use of a helper routine
  • Typical challenge: Missing or inconsistent direction logic leads to non-reproducible step sequences

Work assignment (excerpt)

1. Add the class Robot with methods for moving down and left. 2. Use the existing rotation helper method and then call move() subsequently. 3. Control the instance step by step so that the target point is reached.

Example (excerpt)

The fragment is didactically relevant because it demonstrates the reuse of a helper method and encapsulation of an action as a method in the class.

1
2
3
4
5
6
7
8
class Roboter:
    def _drehe_zu(self, ziel):
        while richtung() != ziel:
            rechts_drehen()

    def links(self):
        self._drehe_zu("left")
        bewegen()

Hints for teaching practice

This building block connects classes as models with a step-by-step method implementation and makes results transparent over traceable call sequences.

The clear task structure supports rapid lesson organization and facilitates result security through defined methods and their use. Differentiation is possible through additional movement logic or alternative step sequences.

Request access to the demo and test the building block in your own course context to accompany the transition from functions to classes specifically.