1 / 10

Programmieren

Programmieren. Kapitel 2 – Programmfluss. Ziele von Heute. Kurze Repetition vom letzten Mal Flussdiagramme Programmfluss steuern Übungen mit Kara. Lernkontrolle zu Kapitel 1. Lernkontrolle Frage 1. Welt. Klassen-diagramm. Objekt. Klassen. Kompilieren (Übersetzen).

roger
Télécharger la présentation

Programmieren

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programmieren Kapitel 2 – Programmfluss

  2. Ziele von Heute • Kurze Repetition vom letzten Mal • Flussdiagramme • Programmfluss steuern • Übungen mit Kara Programmieren / Kapitel 2 - Programmfluss

  3. Lernkontrolle zu Kapitel 1 Programmieren / Kapitel 2 - Programmfluss

  4. Lernkontrolle Frage 1 Welt Klassen-diagramm Objekt Klassen Kompilieren (Übersetzen) Programmieren / Kapitel 2 - Programmfluss

  5. Lernkontrolle Frage 2 • Was macht eine Methode mit void als Rückgabetyp? • Führt eine Aktion aus, gibt aber kein Resultat zurück. • Was macht eine Methode mit boolean als Rückgabetyp? • Gibt als Resultat einen boolean zurück. • Welche Werte kann booleanhaben? • true und false Programmieren / Kapitel 2 - Programmfluss

  6. Kurzer Exkurs zu Boolean • Boolesche Algebra:Entwickelt vom Mathematiker George Boole im 19. Jh. • Beispiel Pizza Prosciutto: • «Enthält Schinken»  true / false? • «Enthält Käse und Pilze»  ? • «Enthält Käse oder Pilze»  ? Programmieren / Kapitel 2 - Programmfluss

  7. Lernkontrolle • Was ist der Unterschied zwischen move() und act() in unserem Kara-Szenario? • move() bewegt Kara um eins vorwärts. • In act() können beliebige Methoden aufgerufen werden. • Was bedeutet Kompilieren? Weshalb ist es nötig? • Kompilieren ist die Übersetzung von Quelltext in Maschinencode, damit es der Computer verstehen kann. Programmieren / Kapitel 2 - Programmfluss

  8. Aufgabe 7 publicclassMyKaraextends Kara { publicvoidact() { move(); turnLeft(); move(); turnRight(); move(); move(); turnRight(); move(); turnLeft(); turnLeft(); move(); turnRight(); move(); move(); turnRight(); move(); turnLeft(); removeLeaf(); } } turnLeft(); move(); turnRight(); move(); move(); turnRight(); move(); turnLeft(); move(); Programmieren / Kapitel 2 - Programmfluss

  9. Aufgabe 8 publicvoidgoAroundTree() { turnLeft(); move(); turnRight(); move(); move(); turnRight(); move(); turnLeft(); } public void act() { move(); goAroundTree();goAroundTree(); move(); goAroundTree();removeLeaf(); } Programmieren / Kapitel 2 - Programmfluss

  10. Was, wenn sich die Wiese ändert? public void act() { move(); goAroundTree();goAroundTree(); move(); goAroundTree();removeLeaf(); } Was passiert auf dieser Wiese? Programmieren / Kapitel 2 - Programmfluss

More Related