-
Notifications
You must be signed in to change notification settings - Fork 24
L01_Boxes
Jirka Dell'Oro-Friedl edited this page Oct 19, 2021
·
10 revisions
- Erstelle eine Tracetable zu untenstehendem TypeScript-Code.
- Stelle die zu erwartende Ausgabe grafisch auf Papier dar.
- Bringe schließlich den Code zum Laufen und überprüfe das Ergebnis.
- Verfolge den Verlauf im Debugger. Bestimme Abweichungen zu deiner Erwartung und erkläre diese. Experimentiere mit den Möglichkeiten des Debuggers.
- Konstruiere ein ausführliches Aktivitätsdiagramm für den Programmablauf. Nutze dafür das EIA2-Booklet sowie das Beispiel aus der ersten Lektion.
namespace Boxes {
let n: number = 5;
let color: string;
let x: number = 0;
let y: number = 0;
for (let i: number = 0; i < n; i++) {
y += (i == 2) ? 20 : 50;
x = (x + 170) % 400;
switch (i) {
case 0:
color = "#ff0000";
break;
case 1:
case 4:
color = "#00ff00";
break;
case 3:
continue;
default:
color = "#0000ff";
}
for (let size of ["big", "medium", "small"]) {
createBox(color, x, y, size);
if (i == 4)
break;
}
}
function createBox(_color: string, _x: number, _y: number, _size: string): void {
let div: HTMLDivElement = document.createElement("div");
document.body.appendChild(div);
div.classList.add(_size);
div.style.backgroundColor = _color;
div.style.left = _x + "px";
div.style.top = _y + "px";
}
}
div {
border: thick solid black;
position: absolute;
}
.big {
width: 50px;
height: 50px;
}
.medium {
width: 30px;
height: 30px;
}
.small {
width: 10px;
height: 10px;
}
L00_Preparation
L01_Zufallsgedicht
Übung: L01_Boxes
L02_EventInspector
L03_Aufgabenliste_Formular
L04_Aufgabenliste_Datenstruktur
L05_Client
L06_DatabaseServer
L08.1_GenerativeKunst
L08.2_Vogelhaus: Canvas
L09.1_OldMacDonaldsFarm
L09.2_Vogelhaus: Classes
L10.1_OldMacDonaldsHeritage
L10.2_Vogelhaus: Polymorphie
Abschlussarbeit: Feuerwerk!