Skip to Content
Entwurfsmuster von Kopf bis Fubß
book

Entwurfsmuster von Kopf bis Fubß

by Eric Freeman, Elisaebth Freeman, Kathy Sierra, Bert Bates
December 2005
Beginner to intermediate
672 pages
14h 12m
German
O'Reilly Verlag
Content preview from Entwurfsmuster von Kopf bis Fubß

10.3. Den Code schreiben

Jetzt ist es Zeit, den Kaugummiautomaten zu implementieren. Wir wissen, dass wir eine Instanzvariable haben, die den aktuellen Zustand enthält. Darüber müssen wir alle Aktionen und möglichen Zustandsübergänge sowie das gesamte Verhalten steuern. Bei den Aktionen müssen wir implementieren: Münzeinwurf, Münzauswurf, Drehen des Griffs und Ausgabe einer Kugel. Außerdem muss auch die Möglichkeit, dass der Automat leer ist, mit implementiert werden.

public class KaugummiAutomat { final static int AUSVERKAUFT = 0; final static int KEINE_MÜNZE = 1; final static int HAT_MÜNZE = 2; final static int VERKAUFT = 3; int zustand = AUSVERKAUFT; int anzahl = 0; public KaugummiAutomat(int anzahl) { this.anzahl = anzahl; if (anzahl > 0) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Netzwerke von Kopf bis Fuß

Netzwerke von Kopf bis Fuß

Al Anderson, Ryan Benedetti
JavaScript-Programmierung von Kopf bis Fuß

JavaScript-Programmierung von Kopf bis Fuß

Eric Freeman, Elisabeth Robson
Servlets und JSPs™ von Kopf bis Fuß

Servlets und JSPs™ von Kopf bis Fuß

Bryan Basham, Kathy Sierra, Bert Bates
Programmieren von Kopf bis Fuß

Programmieren von Kopf bis Fuß

David Griffiths, Paul Barry

Publisher Resources

ISBN: 9783897214217Errata Page