You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 7, 2026. It is now read-only.
Repository navigation
Commit 6b56b51
Browse filesBrowse the repository at this point in the historyBrowse files
Web 0.14.27: VisuBot forward/backward mit Einheit (Überladung) + Messprotokoll (#257)
* Web 0.14.27: VisuBot forward/backward mit Einheit (cm, Umdrehungen) als Überladung
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ugz28X194soXJc3xm99DAM
* Messprotokoll Radumdrehung (PDF) und Angeberwissen in VisuBot-Lektion 22
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ugz28X194soXJc3xm99DAM
---------
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ The format is loosely inspired by Keep a Changelog.
8
8
9
9
### Changed
10
10
11
+
- **Web 0.14.27, VisuBot: `forward`/`backward` overloaded with a unit:** besides `mbot.forward()` (10 cm) and `mbot.forward(30)` there is now `mbot.forward(2, "Umdrehungen")` and `mbot.forward(30, "cm")` (en `"rotations"`, pt `"rotações"`), same for `backward`. One wheel rotation is π · 6.5 cm ≈ 20.4 cm; the action stores the distance in cm, so simulation, exercise check and the real robot (`mbot2.straight`) work unchanged, and the console shows e.g. „2 Umdrehungen vorwärts (40.84 cm)“. An unknown unit is an error naming the allowed units. The CyberPi program export gets the same overload. VisuBot lesson 22 gets a step „Gleicher Name, andere Parameter: Überladung“ with the three headers, a Ludwig Angeberwissen asking pupils to measure their own robot with a printable test record (PDF, de/en, `website/visubot/messprotokoll-radumdrehung.pdf` / `test-record-wheel-rotation.pdf`: wheel diameter, five test cases expected vs. actual, evaluation, causes, feedback for the teacher, box „So testet man Softwaresysteme“), the exercise „Quadrat mit Umdrehungen“ and a quiz; Nachschlagen, glossary („Überladung“) and code completion list the new variants (de/en).
11
12
-**Web 0.14.26, animation: nested loop fills a times table in lesson 14:** in step „Schleife in der Schleife“, after the triangle example (which keeps the names `zeile`/`stern`), a new sentence says experienced programmers call the counters `i` and `j`, followed by an animated structure chart: the active block lights up, a variables box shows `i`, `j` and `text` (pt `texto`), and the console fills line by line with `1 2 3 4`, `2 4 6 8`, `3 6 9 12`. It shows that `j` starts again at 1 on every new line. Plays once when visible, „Noch einmal abspielen“ replays it (de/en/pt).
12
13
-**Web 0.14.25, „Bombe entschärfen“: tap part of a line:** a bomb round can name the wrong part with `stelle:` (e.g. `stelle: i++`). Such rounds show the parts of every line as tappable boxes (the three fields of a `for` header, the condition of `if`/`while`, target and value of an assignment, call and arguments split at `+`); right line but wrong part gives its own hint. Lesson 13 (6 of 8 rounds) and lesson 15 (all 6 rounds) use it (de/en/pt, texts in all 21 languages).
13
14
-**Web 0.14.24, animation: while becomes for in lesson 13:** step 2 „Zählen mit festem Plan“ of the for loop lesson shows an animated structure chart: the while loop's start value (`int i = 1`), condition (`i <= 5`) and step (`i++`) light up one after another in their own colour and then move together into the head of the for loop, labelled Start, Bedingung, Schritt (en Init/Condition/Step, pt Início/Condição/Passo). It plays once when it scrolls into view; „Noch einmal abspielen“ replays it. With reduced motion only the end state is shown. New lesson block `::: grafik datei.svg animiert` (own SVG with CSS animation, no library).
Mehrere Methoden mit demselben Namen, aber verschiedenen Parametern, z. B. `mbot.forward(30)` und `mbot.forward(2, "Umdrehungen")`. Java wählt beim Aufruf die passende nach Anzahl und Typ der Parameter.
151
+
148
152
### Spaghetticode
149
153
Ein Programm, das so kreuz und quer springt, dass man den Ablauf kaum noch verfolgen kann. Struktogramme verhindern das.
Copy file name to clipboardExpand all lines: web/lessons/de/visubot/22-eigene-methoden.md
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ kurz: Eigene Befehle mit Parametern und Rückgabewert schreiben und aufrufen.
9
9
::: kompetenzen
10
10
- ein Unterprogramm mit Parameter bauen und aufrufen
11
11
- Methoden in Java erkennen
12
+
- eine überladene Methode erkennen und aufrufen
12
13
- eine Methode mit Rückgabewert schreiben
13
14
:::
14
15
@@ -70,6 +71,54 @@ Im Bereich [Code](#zeige-codelive) siehst du jede Methode in ihrem eigenen Reite
70
71
> Der Wert in den Klammern des Aufrufs wird zum Parameter `seite`.
71
72
:::
72
73
74
+
## Gleicher Name, andere Parameter: Überladung
75
+
76
+
Du kennst `mbot.forward()` und `mbot.forward(30)`. Das sind **zwei verschiedene Methoden mit demselben Namen**. Java erkennt am Aufruf, welche gemeint ist: an der **Anzahl** und am **Typ** der Parameter. Das nennt man **Überladung** (englisch *overloading*).
77
+
78
+
Es gibt noch eine dritte `forward`-Methode. Sie hat zwei Parameter: eine Zahl und eine **Einheit** als Text.
79
+
80
+
```java
81
+
mbot.forward(); // 10 cm (Standardwert)
82
+
mbot.forward(30); // 30 cm
83
+
mbot.forward(30, "cm"); // 30 cm, Einheit ausdrücklich
84
+
mbot.forward(2, "Umdrehungen"); // die Räder drehen sich zweimal
85
+
```
86
+
87
+
Eine Radumdrehung ist so weit wie der Umfang des Rads: π · 6,5 cm ≈ 20,4 cm. Zwei Umdrehungen sind also etwa 40,8 cm. Für `mbot.backward` gibt es dieselben drei Varianten.
88
+
89
+
So sehen die drei Kopfzeilen aus. Der Methodenname ist gleich, die Parameterlisten sind verschieden:
90
+
91
+
```java
92
+
void forward()
93
+
void forward(int cm)
94
+
void forward(int wert, String einheit)
95
+
```
96
+
97
+
Überladung kennst du schon: `System.out.println` gibt es für `int`, für `double`, für `String` und noch mehr. Deshalb kannst du jeden dieser Werte einfach in die Klammern schreiben.
98
+
99
+
::: angeberwissen
100
+
Stimmen die 20,4 cm bei **deinem** mBot2 wirklich? Profis glauben keiner Zahl, die sie nicht nachgemessen haben. Miss den Raddurchmesser und lass `mbot.forward(5, "Umdrehungen")` fahren: Soll sind 102,1 cm. So testet man Softwaresysteme: Jeder **Testfall** hat ein erwartetes Ergebnis (**Soll**) und ein gemessenes (**Ist**). Man testet mehrmals und schreibt alles in ein **Protokoll**. Hier ist dein [Messprotokoll zum Ausdrucken (PDF)](https://visustruct.org/visubot/messprotokoll-radumdrehung.pdf). Gib es deiner Lehrkraft, dann sieht sie, ob alle Roboter gleich weit fahren.
101
+
:::
102
+
103
+
::: übung vb-ueberladung-umdrehung
104
+
titel: Quadrat mit Umdrehungen
105
+
auftrag: Fahre ein Quadrat, bei dem jede Seite genau **eine Radumdrehung** lang ist. Nimm dafür die überladene Methode `mbot.forward(1, "Umdrehungen")`.
106
+
fahrt: 4 x (forward 20.42, turnRight)
107
+
braucht: forSchleife
108
+
tipp: Eine For-Schleife mit `int i = 0`, `i < 4`, `i++`.
109
+
tipp: Im Inhalt stehen `mbot.forward(1, "Umdrehungen")` und `mbot.turnRight()`.
? Welche Methode ruft `mbot.forward(3, "Umdrehungen")` auf?
115
+
→ Gleicher Name, andere Parameter: Überladung
116
+
-[ ]`forward()`
117
+
-[ ]`forward(int cm)`
118
+
-[x]`forward(int wert, String einheit)`
119
+
> Java wählt die Variante, deren Parameter passen: zwei Parameter, eine Zahl und ein Text.
120
+
:::
121
+
73
122
## Jetzt ohne Roboter: Methode mit Rückgabe
74
123
75
124
Eine Methode kann auch etwas **ausrechnen** und das Ergebnis zurückgeben. Statt `void` steht dann der Datentyp des Ergebnisses in der Kopfzeile, und `return` gibt den Wert zurück:
@@ -98,5 +147,6 @@ Schätze dich bei jedem Punkt ehrlich ein: ☂️ noch nicht, ⛅ teilweise, ☀
98
147
::: checkliste
99
148
- Ich kann ein Unterprogramm mit Parameter bauen und aufrufen. → Ein Unterprogramm für das Quadrat
100
149
- Ich kann Methoden in Java erkennen. → Methoden in Java
150
+
- Ich kann eine überladene Methode erkennen und aufrufen. → Gleicher Name, andere Parameter: Überladung
101
151
- Ich kann eine Methode mit Rückgabewert schreiben. → Jetzt ohne Roboter: Methode mit Rückgabe
Copy file name to clipboardExpand all lines: web/lessons/de/visubot/nachschlagen.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,13 +9,17 @@ Der mBot2 fährt geradeaus oder dreht sich auf der Stelle.
9
9
```
10
10
mbot.forward() fährt 10 cm nach vorn
11
11
mbot.forward(30) fährt 30 cm nach vorn
12
+
mbot.forward(2, "Umdrehungen") die Räder drehen sich 2-mal (≈ 41 cm)
13
+
mbot.backward(1, "Umdrehungen") eine Radumdrehung zurück (≈ 20 cm)
12
14
mbot.backward(20) fährt 20 cm zurück
13
15
mbot.turnRight() dreht sich nach rechts (90°)
14
16
mbot.turnLeft() dreht sich nach links (90°)
15
17
mbot.turnLeft(45) dreht sich nur ein bisschen nach links (45°)
16
18
mbot.turnRight(180) dreht sich ganz um
17
19
```
18
20
21
+
> `forward` und `backward` sind **überladen**: gleicher Name, verschiedene Parameter. Als Einheit gehen `"cm"` und `"Umdrehungen"`. Eine Radumdrehung sind etwa 20,4 cm.
22
+
19
23
> Ohne Zahl fährt er 10 cm oder dreht sich 90°. 90° ist ein rechter Winkel, wie die Ecke von einem Blatt Papier.
20
24
21
25
> Für ein Vieleck dreht er sich insgesamt einmal ganz herum: Dreieck 3 × 120°, Quadrat 4 × 90°, Sechseck 6 × 60°.
Copy file name to clipboardExpand all lines: web/lessons/en/begriffe.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -151,6 +151,10 @@ A structure chart of its own for part of a task. It runs when it is called. In J
151
151
also: parameter, parameters, Parameters
152
152
A variable in the header line of a subprogram. When it is called, it gets the value from the parentheses.
153
153
154
+
### Overloading
155
+
also: overloaded, overload
156
+
Several methods with the same name but different parameters, e.g. `mbot.forward(30)` and `mbot.forward(2, "rotations")`. When calling, Java picks the right one by the number and type of the parameters.
157
+
154
158
### Spaghetti code
155
159
also: spaghetti code
156
160
A program that jumps around so wildly that you can hardly follow what happens. Structure charts prevent that.
Copy file name to clipboardExpand all lines: web/lessons/en/visubot/22-eigene-methoden.md
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ kurz: Write and call your own commands with parameters and return values.
9
9
::: kompetenzen
10
10
- build and call a subprogram with a parameter
11
11
- recognise methods in Java
12
+
- recognise and call an overloaded method
12
13
- write a method with a return value
13
14
:::
14
15
@@ -70,6 +71,54 @@ In [Code](#zeige-codelive) you see each method in its own tab, just like in the
70
71
> The value in the brackets of the call becomes the parameter `side`.
71
72
:::
72
73
74
+
## Same name, different parameters: overloading
75
+
76
+
You know `mbot.forward()` and `mbot.forward(30)`. These are **two different methods with the same name**. Java can tell from the call which one is meant: by the **number** and the **type** of the parameters. This is called **overloading**.
77
+
78
+
There is a third `forward` method. It has two parameters: a number and a **unit** as text.
79
+
80
+
```java
81
+
mbot.forward(); // 10 cm (default)
82
+
mbot.forward(30); // 30 cm
83
+
mbot.forward(30, "cm"); // 30 cm, unit written out
84
+
mbot.forward(2, "rotations"); // the wheels turn twice
85
+
```
86
+
87
+
One wheel rotation is as far as the wheel's circumference: π · 6.5 cm ≈ 20.4 cm. So two rotations are about 40.8 cm. `mbot.backward` has the same three versions.
88
+
89
+
These are the three headers. The method name is the same, the parameter lists are different:
90
+
91
+
```java
92
+
void forward()
93
+
void forward(int cm)
94
+
void forward(int value, String unit)
95
+
```
96
+
97
+
You already know overloading: `System.out.println` exists for `int`, for `double`, for `String` and more. That is why you can simply put any of these values in the brackets.
98
+
99
+
::: angeberwissen
100
+
Are the 20.4 cm really true for **your** mBot2? Professionals don't trust a number they haven't measured. Measure the wheel diameter and run `mbot.forward(5, "rotations")`: the expected distance is 102.1 cm. This is how software systems are tested: every **test case** has an expected result and an actual (measured) result. You test several times and write everything into a **test record**. Here is your [test record to print (PDF)](https://visustruct.org/visubot/test-record-wheel-rotation.pdf). Give it to your teacher, so they can see whether all robots drive the same distance.
101
+
:::
102
+
103
+
::: übung vb-ueberladung-umdrehung
104
+
titel: Square with rotations
105
+
auftrag: Drive a square in which every side is exactly **one wheel rotation** long. Use the overloaded method `mbot.forward(1, "rotations")`.
106
+
fahrt: 4 x (forward 20.42, turnRight)
107
+
braucht: forSchleife
108
+
tipp: A for loop with `int i = 0`, `i < 4`, `i++`.
109
+
tipp: Inside are `mbot.forward(1, "rotations")` and `mbot.turnRight()`.
? Which method does `mbot.forward(3, "rotations")` call?
115
+
→ Same name, different parameters: overloading
116
+
-[ ]`forward()`
117
+
-[ ]`forward(int cm)`
118
+
-[x]`forward(int value, String unit)`
119
+
> Java picks the version whose parameters fit: two parameters, a number and a text.
120
+
:::
121
+
73
122
## Now without the robot: a method with a return value
74
123
75
124
A method can also **calculate** something and give the result back. Instead of `void`, the header then names the data type of the result, and `return` gives the value back:
@@ -98,5 +147,6 @@ Rate yourself honestly for each point: ☂️ not yet, ⛅ partly, ☀️ I can
98
147
::: checkliste
99
148
- I can build and call a subprogram with a parameter. → A subprogram for the square
100
149
- I can recognise methods in Java. → Methods in Java
150
+
- I can recognise and call an overloaded method. → Same name, different parameters: overloading
101
151
- I can write a method with a return value. → Now without the robot: a method with a return value
Copy file name to clipboardExpand all lines: web/lessons/en/visubot/nachschlagen.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,13 +9,17 @@ The mBot2 drives straight or turns on the spot.
9
9
```
10
10
mbot.forward() drives 10 cm forward
11
11
mbot.forward(30) drives 30 cm forward
12
+
mbot.forward(2, "rotations") the wheels turn twice (≈ 41 cm)
13
+
mbot.backward(1, "rotations") one wheel rotation back (≈ 20 cm)
12
14
mbot.backward(20) drives 20 cm back
13
15
mbot.turnRight() turns to the right (90°)
14
16
mbot.turnLeft() turns to the left (90°)
15
17
mbot.turnLeft(45) turns just a little to the left (45°)
16
18
mbot.turnRight(180) turns all the way round
17
19
```
18
20
21
+
> `forward` and `backward` are **overloaded**: same name, different parameters. Units are `"cm"` and `"rotations"`. One wheel rotation is about 20.4 cm.
22
+
19
23
> Without a number it drives 10 cm or turns 90°. 90° is a right angle, like the corner of a sheet of paper.
20
24
21
25
> For a polygon it turns all the way round once in total: triangle 3 × 120°, square 4 × 90°, hexagon 6 × 60°.
0 commit comments