diff options
26 files changed, 466 insertions, 2 deletions
diff --git a/Info/9/3/Planet/.gitignore b/Info/9/3/Planet/.gitignore index 89b66212..7c638fd3 100644 --- a/Info/9/3/Planet/.gitignore +++ b/Info/9/3/Planet/.gitignore @@ -5,3 +5,5 @@ plots/ *.log *.aux _minted/ +*.fdb_latexmk +*.fls diff --git a/Info/9/3/Planet/Makefile b/Info/9/3/Planet/Makefile index 3aadc6a4..2d59c81e 100644 --- a/Info/9/3/Planet/Makefile +++ b/Info/9/3/Planet/Makefile @@ -2,7 +2,8 @@ PRINTOUT=modellierung/landung/modellierung.pdf \ modellierung/zwischenlager/methoden-testen.pdf \ modellierung/zwischenlager/methoden-schreiben.pdf \ algorithmik/sequenzen/sequenzen.pdf \ - algorithmik/while/bedingte-wiederholung.pdf + algorithmik/while/bedingte-wiederholung.pdf \ + algorithmik/if/bedingte-anweisung.pdf PLOTSRCS := $(shell find -name "*.plantuml") TIKSSRC := $(shell find -name "*.tikz") @@ -35,17 +36,31 @@ all: $(PLOTS) $(SRC:.md=.html) $(PRINTOUT) slides.pdf slides.pptx plantuml --svg $< > $@ %.svg: %.tikz - tikztosvg -l shapes.geometric -l arrows.meta -l positioning -l calc -p struktex -o $@ $< + TEXINPUTS="$(@D):" tikztosvg -p graphicx -l shapes.geometric -l arrows.meta -l positioning -l calc -p struktex -o $@ $< inkscape --actions="page-fit-to-selection" -o $@ $@ algorithmik/while/bedingte-wiederholung.html: algorithmik/while/tuwas.svg +algorithmik/if/bedingte-anweisung.html: algorithmik/if/code1.svg algorithmik/if/code2.svg algorithmik/if/wastueich.svg + algorithmik/while/tuwas.pdf: algorithmik/while/tuwas.tex latexmk -pdf -outdir=$(@D) $< algorithmik/while/tuwas.svg: algorithmik/while/tuwas.pdf pdf2svg $< $@ +algorithmik/if/code%.pdf: algorithmik/if/code%.tex + latexmk -pdf -outdir=$(@D) $< + +algorithmik/if/wastueich.pdf: algorithmik/if/wastueich.tex + latexmk -pdf -outdir=$(@D) $< + +algorithmik/if/%.svg: algorithmik/if/%.pdf + pdf2svg $< $@ + +algorithmik/if/code%.svg: algorithmik/if/code%.pdf + pdf2svg $< $@ + slides.pdf: slides.md $(MAKE) -f Makefile.slides slides.pdf diff --git a/Info/9/3/Planet/algorithmik/if/.gitignore b/Info/9/3/Planet/algorithmik/if/.gitignore new file mode 100644 index 00000000..61317519 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/.gitignore @@ -0,0 +1 @@ +*.svg
\ No newline at end of file diff --git a/Info/9/3/Planet/algorithmik/if/bedingte-anweisung.md b/Info/9/3/Planet/algorithmik/if/bedingte-anweisung.md index 0edf6cc1..a337a7f7 100644 --- a/Info/9/3/Planet/algorithmik/if/bedingte-anweisung.md +++ b/Info/9/3/Planet/algorithmik/if/bedingte-anweisung.md @@ -1,2 +1,255 @@ +--- +section: Bedingte Anweisung +title: Bedingte Anweisung +--- + +:::{.no-print} +:::{.tipp} +Vergiss nicht das Arbeitsblatt: %section% herunterzuladen. +:::: +::: + :::{.terminal} +Auf unserem Weg durch das Geröllfeld liegt manchmal direkt vor uns ein Hügel. +Wir müssen diese Situationen erkennen und die Berge umfahren. +Dazu verwenden wir eine **bedingte Anweisung**. +_ +::: + +#### Schritt 5.1 + +::::{.tipp style="margin-top: 1em;"} +Unser Ausbildungsteam hat einen Learningsnack dazu erstellt: Learningsnack: Bedingte Anweisung. +::: + +:::{.merke data-class="Merke: Bedingte Anweisung"} +Mit einer **bedingten Anweisung** (*if-Anweisung*) können bestimmte [Anweisungen]{color="orange"} unter gewissen Bedingungen ausgeführt werden. +[Nur]{.underline} falls (engl. *if*) die [Bedingung]{color=Magenta} **wahr** ist, werden die Anweisungen ausgeführt. + +:::: {.columns} +::::: {.column width=33%} +**Programmcode:** + +<code style="white-space: pre;"> +if([Bedingung]{color="magenta"})<br> +{<br> +[Anweisungen]{style="color: orange; margin-left: 20px;"}<br> +} +</code> +::::: + +::::: {.column width=33%} +**Programmablauf:** + + +::::: + +::::: {.column width=33%} +**Struktogramm:** + + +::::: +:::: +::: + +:::{.aufgabe data-class="Aufgabe 5.1"} +::: {.columns} +:::: {.column width=50%} +Der Rover soll nur dann fahren, wenn vor ihm kein Hügel ist. +Mit dem Methodenaufruf `huegelVorhanden("vorne")` kannst du prüfen, ob vor dem Rover ein Hügel liegt. +:::: + +:::: {.column width=50%} + +:::: +::: +:::: {.columns} +::::: {.column width=50%} +**Programmcode:** +<div style="height: 7cm;"></div> +::::: + +::::: {.column width=50%} +**Struktogramm:** +::::: +:::: +::: + +#### Schritt 5.2 + +Der Rover kann Gesteine aufheben. +Um Energie zu sparen, soll er jedoch nur danach greifen, wenn auch wirklich Gestein unter ihm liegt. + +:::{.aufgabe data-class="Aufgabe 5.2"} +Implementiere die neue Methode `nimmGesteinFallsVorhanden()` der Klasse `Rover`. +Dabei soll der Rover nur dann versuchen Gestein aufzuheben, wenn unter ihm wirklich welches ist. + +::::{.tipp style="margin-top: -0.5em; margin-bottom: 0.5em;"} +**Hinweis:** Mit seinem Sensor kann er überprüfen, ob Gestein vorhanden ist (→ Methode: `gesteinVorhanden()`). +:::: +::: + +#### Schritt 5.3 + +::: {.columns} +:::: {.column width=65%} +Wie du bereits weißt, kann der Rover Felder mit einem Hügel nicht befahren. +Mit seinem Sensor kann er überprüfen, ob sich auf dem Feld vor ihm ein Hügel befindet (→ Methode: `huegelVorhanden("vorne")`{.java}). +Ist dies der Fall, soll er sich nach rechts drehen und den Hügel umfahren. +:::: + +:::: {.column width=35%} + +:::: +::: + +:::{.aufgabe data-class="Aufgabe 5.3"} +:::: {.columns} +::::: {.column width=70%} +Vervollständige die entsprechende Methode `huegelUmfahren()` in der Klasse `Rover`. + +**Test**: Teste deine Methoden mit der Datei *Bedingte Anweisung* in der Online-IDE. +::::: + +::::: {.column width=30%} + +::::: +:::: +::: + +:::{.terminal} +Unserem Wissenschafts-Team ist eben aufgefallen, dass es praktisch wäre, wenn man einfach gerade ausfahren kann, wenn *kein* Hügel vor dem Rover ist. +Die Technik-Abteilung meint aber der Rover und du ihr bekommt das schon hin. +_ +::: + +#### Schritt 5.4 + +:::{.merke data-class="Merke: Bedingte Anweisung mit Alternative"} +Mit einer **bedingten Anweisung mit Alternative** (*if-else-Anweisung*) werden im Gegensatz zur bedinten Anweisung im *else*-Teil alternative Anweisungen ([Anweisungen 2]{color="orange"}) ausgeführt, falls die [Bedingung]{color=Magenta} **falsch** ist. + +::: {.columns} +:::: {.column width=33%} +**Programmcode:** + +<code style="white-space: pre;"> +if([Bedingung]{color="magenta"})<br> +{<br> +[Anweisungen 1]{style="color: orange; margin-left: 20px;"}<br> +} +else<br> +{<br> +[Anweisungen 2]{style="color: orange; margin-left: 20px;"}<br> +} +</code> +:::: + +:::: {.column width=33%} +**Programmablauf:** + + +:::: + +:::: {.column width=33%} +**Struktogramm:** + + +:::: +::: +::: + +:::{.aufgabe data-class="Aufgabe 5.4"} +Der Rover soll nur dann fahren, wenn kein Hügel vorhanden ist. +Ansonsten soll er außenrumfahren. + +::: {.columns} +:::: {.column width=60%} +Kein Hügel vorhanden? +Dann fahre vorwärts! +{.center} +:::: + +:::: {.column width=5%} +<span style="font-size:2em;">**→**</span> +:::: + +:::: {.column width=35%} + +:::: +::: + +::: {.columns} +:::: {.column width=60%} +Hügel vorhanden? +Dann fahre am Hügel vorbei! +{.center} +:::: + +:::: {.column width=5%} +<span style="font-size:2em;">**→**</span> +:::: + +:::: {.column width=35%} + +:::: +::: + +:::: {.columns} +::::: {.column width=50%} +**Programmcode:** +<div style="height: 10cm;"></div> +::::: + +::::: {.column width=50%} +**Struktogramm:** +::::: +:::: +::: + +:::{.page-break} +::: + +#### Schritt 5.5 + +::: {.columns} +:::: {.column width=50%} +:::::{.aufgabe data-class="Aufgabe 5.5"} +Beschreibe nebenstehende bedingte Anweisungen mit Alternative (Code 1 und Code 2). +Verwende folgende Begriffe: *if-Teil*, *else-Teil*, *Methode*, *Bedingung*, *wahr*, *falsch*. +::::: + + +:::: + +:::: {.column width=50%} + +:::: +::: + +::: {.columns} +:::: {.column width=50%} +:::::{.aufgabe data-class="Aufgabe 5.6"} +Analysiere die Methode `wastueich()` und skizziere, wie die abgebildete Welt nach Aufruf der Methode aussieht. +::::: + + +:::: + +:::: {.column width=50%} + +:::: +::: + +#### Zusatzaufgabe 5.1 + +:::{.aufgabe} +Zeichne die Struktogramme zum **Code aus Aufgabe 5.5 und 5.6**. +Verwende dazu das Online-Tool, der Uni Dresden: <https://ddi.education/struktog/> +::: + +:::{.erledigt} +::: + +:::{.no-print} +<< Zurück zu TODO: %section% ::: diff --git a/Info/9/3/Planet/algorithmik/if/code1.tex b/Info/9/3/Planet/algorithmik/if/code1.tex new file mode 100644 index 00000000..dd1a3c96 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/code1.tex @@ -0,0 +1,18 @@ +\documentclass[border={8mm, 0mm, 2mm, 0mm}, varwidth]{standalone} +\usepackage{minted} +\begin{document} +\begin{minipage}{6cm} +\begin{minted}[ +linenos, +]{java} +if(gesteinVorhanden()) +{ + fahre(); +} +else +{ + setzeMarke(); +} +\end{minted} +\end{minipage} +\end{document} diff --git a/Info/9/3/Planet/algorithmik/if/code2.tex b/Info/9/3/Planet/algorithmik/if/code2.tex new file mode 100644 index 00000000..792cbd53 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/code2.tex @@ -0,0 +1,28 @@ +\documentclass[border={8mm, 0mm, 2mm, 0mm}, varwidth]{standalone} +\usepackage{minted} +\begin{document} +\begin{minipage}{6cm} +\begin{minted}[ +linenos, +]{java} +if(huegelVorhanden("rechts")) +{ + fahre(); + drehe("rechts"); + fahre(); + fahre(); + drehe("rechts"); + fahre(); + fahre(); + drehe("rechts"); + fahre(); + fahre(); + drehe("rechts"); +} +else +{ + setzeMarke(); +} +\end{minted} +\end{minipage} +\end{document} diff --git a/Info/9/3/Planet/algorithmik/if/else-flowchart.tikz b/Info/9/3/Planet/algorithmik/if/else-flowchart.tikz new file mode 100644 index 00000000..af04d501 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/else-flowchart.tikz @@ -0,0 +1,34 @@ +\tikzset{ + process/.style={ + rectangle, + minimum width=2.5cm, minimum height=1cm, + draw, + text centered + }, + % Decision (diamond) + decision/.style={ + diamond, aspect=2, + minimum width=2.5cm, minimum height=1cm, + draw, + text centered + }, + % Arrow style + arrow/.style={ + thick, ->, >=Stealth + } +} + +\begin{tikzpicture} + \node (start) {}; + \node[decision, below=of start] (decision) {\textbf{\textcolor{magenta}{Bedingung}}}; + \node[process, below=of decision] (process) {\textbf{\textcolor{orange}{Anweisungen}}}; + \node[below=1.2cm of process] (end) {}; + + % Arrows + \draw[arrow] (start) -- (decision); + \draw[arrow] (decision) -- node[right] {Falsch} (process); + + % Decision branch + \draw[arrow] (decision) -- node[above] {Wahr} ($(decision.east) + (1cm, 0)$) -- ($(decision.east) + (1cm, -3.4cm)$) |- ($(process) - (0, 1.1cm)$); + \draw[arrow] (process) -- (end); +\end{tikzpicture} diff --git a/Info/9/3/Planet/algorithmik/if/if-else-flowchart.tikz b/Info/9/3/Planet/algorithmik/if/if-else-flowchart.tikz new file mode 100644 index 00000000..67317656 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/if-else-flowchart.tikz @@ -0,0 +1,36 @@ +\tikzset{ + process/.style={ + rectangle, + minimum width=2.5cm, minimum height=1cm, + draw, + text centered + }, + % Decision (diamond) + decision/.style={ + diamond, aspect=2, + minimum width=2.5cm, minimum height=1cm, + draw, + text centered + }, + % Arrow style + arrow/.style={ + thick, ->, >=Stealth + } +} + +\begin{tikzpicture} + \node (start) {}; + \node[decision, below=of start] (decision) {\textbf{\textcolor{magenta}{Bedingung}}}; + \node[process, below=of decision] (process1) {\textbf{\textcolor{orange}{Anweisungen1}}}; + \node[process, right=of process1] (process2) {\textbf{\textcolor{orange}{Anweisungen2}}}; + \node[below=1.2cm of process1] (end) {}; + + % Arrows + \draw[arrow] (start) -- (decision); + \draw[arrow] (decision) -- node[right] {Wahr} (process1); + + % Decision branch + \draw[arrow] (process1) -- (end); + \draw[arrow] (decision) -- node[above] {Falsch} ($(decision.east) + (1cm, 0)$) -| (process2); + \draw[arrow] (process2.south) -- ($(process2.south) + (0, -0.4cm)$) |- ($(process1) - (0, 1.1cm)$); +\end{tikzpicture} diff --git a/Info/9/3/Planet/algorithmik/if/if-else-struktogramm.tikz b/Info/9/3/Planet/algorithmik/if/if-else-struktogramm.tikz new file mode 100644 index 00000000..1241bbd6 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/if-else-struktogramm.tikz @@ -0,0 +1,7 @@ +\begin{struktogramm}(70,30) + \ifthenelse[12]{1}{1}{\textcolor{magenta}{Bedingung}}{\hspace{-15mm}wahr}{\hspace{15mm}falsch} + \assign{\textcolor{orange}{Anweisungen1}} + \change + \assign{\textcolor{orange}{Anweisungen2}} + \ifend +\end{struktogramm} diff --git a/Info/9/3/Planet/algorithmik/if/if-struktogramm.tikz b/Info/9/3/Planet/algorithmik/if/if-struktogramm.tikz new file mode 100644 index 00000000..2d789a12 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/if-struktogramm.tikz @@ -0,0 +1,6 @@ +\begin{struktogramm}(70,30) + \ifthenelse[12]{1}{1}{\textcolor{magenta}{Bedingung}}{\hspace{-15mm}wahr}{\hspace{15mm}falsch} + \assign{\textcolor{orange}{Anweisungen}} + \change + \ifend +\end{struktogramm} diff --git a/Info/9/3/Planet/algorithmik/if/img/analysiereUndNimmGestein.png b/Info/9/3/Planet/algorithmik/if/img/analysiereUndNimmGestein.png Binary files differnew file mode 100644 index 00000000..950ce1ea --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/img/analysiereUndNimmGestein.png diff --git a/Info/9/3/Planet/algorithmik/if/img/if-code.png b/Info/9/3/Planet/algorithmik/if/img/if-code.png Binary files differnew file mode 100644 index 00000000..15b55563 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/img/if-code.png diff --git a/Info/9/3/Planet/algorithmik/if/img/oide-bedingteAnweisung.png b/Info/9/3/Planet/algorithmik/if/img/oide-bedingteAnweisung.png Binary files differnew file mode 100644 index 00000000..65919d5b --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/img/oide-bedingteAnweisung.png diff --git a/Info/9/3/Planet/algorithmik/if/img/rover-behind-hill-compact.png b/Info/9/3/Planet/algorithmik/if/img/rover-behind-hill-compact.png Binary files differnew file mode 100644 index 00000000..531b8283 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/img/rover-behind-hill-compact.png diff --git a/Info/9/3/Planet/algorithmik/if/img/rover-clear1.png b/Info/9/3/Planet/algorithmik/if/img/rover-clear1.png Binary files differnew file mode 100644 index 00000000..83e06e0e --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/img/rover-clear1.png diff --git a/Info/9/3/Planet/algorithmik/if/img/rover-clear2.png b/Info/9/3/Planet/algorithmik/if/img/rover-clear2.png Binary files differnew file mode 100644 index 00000000..b8d3e986 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/img/rover-clear2.png diff --git a/Info/9/3/Planet/algorithmik/if/img/rover-hill-compact.png b/Info/9/3/Planet/algorithmik/if/img/rover-hill-compact.png Binary files differnew file mode 100644 index 00000000..3c51d635 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/img/rover-hill-compact.png diff --git a/Info/9/3/Planet/algorithmik/if/img/rover-hill.png b/Info/9/3/Planet/algorithmik/if/img/rover-hill.png Binary files differnew file mode 100644 index 00000000..64328134 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/img/rover-hill.png diff --git a/Info/9/3/Planet/algorithmik/if/img/rover-hills-with-gaps.jpg b/Info/9/3/Planet/algorithmik/if/img/rover-hills-with-gaps.jpg Binary files differnew file mode 100644 index 00000000..d77a18e5 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/img/rover-hills-with-gaps.jpg diff --git a/Info/9/3/Planet/algorithmik/if/img/rover-hills-with-marks.jpg b/Info/9/3/Planet/algorithmik/if/img/rover-hills-with-marks.jpg Binary files differnew file mode 100644 index 00000000..ce5ed658 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/img/rover-hills-with-marks.jpg diff --git a/Info/9/3/Planet/algorithmik/if/img/rover-stones.png b/Info/9/3/Planet/algorithmik/if/img/rover-stones.png Binary files differnew file mode 100644 index 00000000..db887a95 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/img/rover-stones.png diff --git a/Info/9/3/Planet/algorithmik/if/img/wastueich.png b/Info/9/3/Planet/algorithmik/if/img/wastueich.png Binary files differnew file mode 100644 index 00000000..72fa577f --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/img/wastueich.png diff --git a/Info/9/3/Planet/algorithmik/if/todo.md b/Info/9/3/Planet/algorithmik/if/todo.md new file mode 100644 index 00000000..1699762b --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/todo.md @@ -0,0 +1,16 @@ +:::{.terminal} +Die gleichen Anweisungen wiederholen hat uns schon weit gebracht. +Wir können auf Gestein zufahren und es einsammeln. +Auch an Bergketten können wir uns orientieren. + +Doch was machen wir wenn wir unterwegs eine Entscheidung treffen müssen. + +Hier im hinteren Teil des Geröllfeldes lernst du: + +* Wie man logische Aussagen mit einander verknüpft. +* Wie du Sequenzen nur in bestimmten Situationen ausführen kannst. +* Wie du eine Entscheidung in Code, als Ablaufplan und als Struktogramm darstellst. + +Viel Erfolg! Wir zählen auf dich! +_ +::: diff --git a/Info/9/3/Planet/algorithmik/if/umfahren.tikz b/Info/9/3/Planet/algorithmik/if/umfahren.tikz new file mode 100644 index 00000000..84f5f07a --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/umfahren.tikz @@ -0,0 +1,5 @@ +\begin{tikzpicture} + \node{\includegraphics{img/rover-hill-compact.png}}; + \draw[line width=2pt, ->] (-2, -1) -- (-2, -1.5) -- (2.2, -1.5) -- (2.2, 0); + \node[opacity=0.35, scale=5] at (2.4, 0) {\includegraphics{img/rover.png}}; +\end{tikzpicture} diff --git a/Info/9/3/Planet/algorithmik/if/wastueich.md b/Info/9/3/Planet/algorithmik/if/wastueich.md new file mode 100644 index 00000000..8a256a98 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/wastueich.md @@ -0,0 +1,19 @@ +--- +section: Bedingte Anweisung +--- + +::: {.columns} +:::: {.column width=70%} +:::{.terminal} +Skizziere die Auswirkungen der Methode `wastueich()` auf die abgebildete Welt. +_ +::: +:::: + +:::: {.column width=30%} + +:::: +::: + + +<< Zurück zu TODO: %section% diff --git a/Info/9/3/Planet/algorithmik/if/wastueich.tex b/Info/9/3/Planet/algorithmik/if/wastueich.tex new file mode 100644 index 00000000..fe5b5dd5 --- /dev/null +++ b/Info/9/3/Planet/algorithmik/if/wastueich.tex @@ -0,0 +1,24 @@ +\documentclass[border={8mm, 0mm, 2mm, 0mm}, varwidth]{standalone} +\usepackage{minted} +\begin{document} +\begin{minipage}{6cm} +\begin{minted}[ +linenos, +]{java} +void wasTueIch() +{ + while(!markeVorhanden()) + { + if(huegelVorhanden("links")) + { + if(gesteinVorhanden()) + { + nimmGestein(); + } + } + fahre(); + } +} +\end{minted} +\end{minipage} +\end{document} |
