Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.

Commit 6b56b51

Browse 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>
1 parent ae3957f commit 6b56b51

24 files changed

Lines changed: 1803 additions & 1426 deletions

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The format is loosely inspired by Keep a Changelog.
88

99
### Changed
1010

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).
1112
- **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).
1213
- **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).
1314
- **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).

‎web/lessons/de/begriffe.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ Ein eigenes Struktogramm für eine Teilaufgabe. Es wird mit einem Aufruf ausgef
145145
auch: Parametern
146146
Eine Variable in der Kopfzeile eines Unterprogramms. Beim Aufruf bekommt sie den Wert aus den Klammern.
147147

148+
### Überladung
149+
auch: überladen, überladene, überladenen, overloading
150+
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+
148152
### Spaghetticode
149153
Ein Programm, das so kreuz und quer springt, dass man den Ablauf kaum noch verfolgen kann. Struktogramme verhindern das.
150154

‎web/lessons/de/visubot/22-eigene-methoden.md‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ kurz: Eigene Befehle mit Parametern und Rückgabewert schreiben und aufrufen.
99
::: kompetenzen
1010
- ein Unterprogramm mit Parameter bauen und aufrufen
1111
- Methoden in Java erkennen
12+
- eine überladene Methode erkennen und aufrufen
1213
- eine Methode mit Rückgabewert schreiben
1314
:::
1415

@@ -70,6 +71,54 @@ Im Bereich [Code](#zeige-codelive) siehst du jede Methode in ihrem eigenen Reite
7071
> Der Wert in den Klammern des Aufrufs wird zum Parameter `seite`.
7172
:::
7273

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()`.
110+
lösung: vb-ueberladung-umdrehung-loesung.visustruct
111+
:::
112+
113+
::: quiz
114+
? 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+
73122
## Jetzt ohne Roboter: Methode mit Rückgabe
74123

75124
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, ☀
98147
::: checkliste
99148
- Ich kann ein Unterprogramm mit Parameter bauen und aufrufen. → Ein Unterprogramm für das Quadrat
100149
- Ich kann Methoden in Java erkennen. → Methoden in Java
150+
- Ich kann eine überladene Methode erkennen und aufrufen. → Gleicher Name, andere Parameter: Überladung
101151
- Ich kann eine Methode mit Rückgabewert schreiben. → Jetzt ohne Roboter: Methode mit Rückgabe
102152
:::

‎web/lessons/de/visubot/nachschlagen.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ Der mBot2 fährt geradeaus oder dreht sich auf der Stelle.
99
```
1010
mbot.forward() fährt 10 cm nach vorn
1111
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)
1214
mbot.backward(20) fährt 20 cm zurück
1315
mbot.turnRight() dreht sich nach rechts (90°)
1416
mbot.turnLeft() dreht sich nach links (90°)
1517
mbot.turnLeft(45) dreht sich nur ein bisschen nach links (45°)
1618
mbot.turnRight(180) dreht sich ganz um
1719
```
1820

21+
> `forward` und `backward` sind **überladen**: gleicher Name, verschiedene Parameter. Als Einheit gehen `"cm"` und `"Umdrehungen"`. Eine Radumdrehung sind etwa 20,4 cm.
22+
1923
> Ohne Zahl fährt er 10 cm oder dreht sich 90°. 90° ist ein rechter Winkel, wie die Ecke von einem Blatt Papier.
2024
2125
> Für ein Vieleck dreht er sich insgesamt einmal ganz herum: Dreieck 3 × 120°, Quadrat 4 × 90°, Sechseck 6 × 60°.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<struktogramm caption="83;113;117;97;114;101;32;119;105;116;104;32;114;111;116;97;116;105;111;110;115;">
3+
<strelem typ="3" zx="0" zy="0">
4+
<text>105;110;116;32;105;32;61;32;48;</text>
5+
<text>105;32;60;32;52;</text>
6+
<text>105;43;43;</text>
7+
<schleifeninhalt>
8+
<strelem typ="0" zx="0" zy="0">
9+
<text>109;98;111;116;46;102;111;114;119;97;114;100;40;49;44;32;34;114;111;116;97;116;105;111;110;115;34;41;</text>
10+
</strelem>
11+
<strelem typ="0" zx="0" zy="0">
12+
<text>109;98;111;116;46;116;117;114;110;82;105;103;104;116;40;41;</text>
13+
</strelem>
14+
</schleifeninhalt>
15+
</strelem>
16+
</struktogramm>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<struktogramm caption="81;117;97;100;114;97;116;32;109;105;116;32;85;109;100;114;101;104;117;110;103;101;110;">
3+
<strelem typ="3" zx="0" zy="0">
4+
<text>105;110;116;32;105;32;61;32;48;</text>
5+
<text>105;32;60;32;52;</text>
6+
<text>105;43;43;</text>
7+
<schleifeninhalt>
8+
<strelem typ="0" zx="0" zy="0">
9+
<text>109;98;111;116;46;102;111;114;119;97;114;100;40;49;44;32;34;85;109;100;114;101;104;117;110;103;101;110;34;41;</text>
10+
</strelem>
11+
<strelem typ="0" zx="0" zy="0">
12+
<text>109;98;111;116;46;116;117;114;110;82;105;103;104;116;40;41;</text>
13+
</strelem>
14+
</schleifeninhalt>
15+
</strelem>
16+
</struktogramm>

‎web/lessons/en/begriffe.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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
151151
also: parameter, parameters, Parameters
152152
A variable in the header line of a subprogram. When it is called, it gets the value from the parentheses.
153153

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+
154158
### Spaghetti code
155159
also: spaghetti code
156160
A program that jumps around so wildly that you can hardly follow what happens. Structure charts prevent that.

‎web/lessons/en/visubot/22-eigene-methoden.md‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ kurz: Write and call your own commands with parameters and return values.
99
::: kompetenzen
1010
- build and call a subprogram with a parameter
1111
- recognise methods in Java
12+
- recognise and call an overloaded method
1213
- write a method with a return value
1314
:::
1415

@@ -70,6 +71,54 @@ In [Code](#zeige-codelive) you see each method in its own tab, just like in the
7071
> The value in the brackets of the call becomes the parameter `side`.
7172
:::
7273

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()`.
110+
lösung: vb-ueberladung-umdrehung-loesung.visustruct
111+
:::
112+
113+
::: quiz
114+
? 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+
73122
## Now without the robot: a method with a return value
74123

75124
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
98147
::: checkliste
99148
- I can build and call a subprogram with a parameter. → A subprogram for the square
100149
- I can recognise methods in Java. → Methods in Java
150+
- I can recognise and call an overloaded method. → Same name, different parameters: overloading
101151
- I can write a method with a return value. → Now without the robot: a method with a return value
102152
:::

‎web/lessons/en/visubot/nachschlagen.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ The mBot2 drives straight or turns on the spot.
99
```
1010
mbot.forward() drives 10 cm forward
1111
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)
1214
mbot.backward(20) drives 20 cm back
1315
mbot.turnRight() turns to the right (90°)
1416
mbot.turnLeft() turns to the left (90°)
1517
mbot.turnLeft(45) turns just a little to the left (45°)
1618
mbot.turnRight(180) turns all the way round
1719
```
1820

21+
> `forward` and `backward` are **overloaded**: same name, different parameters. Units are `"cm"` and `"rotations"`. One wheel rotation is about 20.4 cm.
22+
1923
> Without a number it drives 10 cm or turns 90°. 90° is a right angle, like the corner of a sheet of paper.
2024
2125
> For a polygon it turns all the way round once in total: triangle 3 × 120°, square 4 × 90°, hexagon 6 × 60°.

‎web/package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)