Skip to content
Snippets Groups Projects
Commit 17cc2783 authored by Peter Hertkorn's avatar Peter Hertkorn
Browse files

Add history for state

parent a27ec0af
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,8 @@ public class PowerOff extends Zustand {
}
public void powerButton() {
s.setZustand(s.getStopZustand());
exit();
s.setZustand(s.getPowerOnHistory());
System.out.println("Anschalten");
}
s.getZustand().entry(); }
}
......@@ -7,6 +7,8 @@ public abstract class PowerOn extends Zustand {
}
public void powerButton() {
exit();
s.setPowerOnHistory(s.getZustand());
s.setZustand(s.getPowerOffZustand());
System.out.println("Ausschalten");
}
......
......@@ -4,6 +4,7 @@ public class Soon {
Zustand stopZustand;
Zustand playZustand;
Zustand powerOffZustand;
Zustand powerOnHistory;
Zustand zustand;
......@@ -12,6 +13,7 @@ public class Soon {
playZustand = new PlayZustand(this);
powerOffZustand = new PowerOff(this);
zustand = powerOffZustand;
powerOnHistory = stopZustand;
}
public Zustand getPowerOffZustand() {
......@@ -69,6 +71,14 @@ public class Soon {
public void volumeDown() {
System.out.println("Leiser");
}
public Zustand getPowerOnHistory() {
return powerOnHistory;
}
public void setPowerOnHistory(Zustand z) {
powerOnHistory = z;
}
public String toString() {
StringBuffer result = new StringBuffer();
......
......@@ -10,6 +10,8 @@ public class SoonTestDrive {
player.powerButton();
player.playButton();
player.volumeUpButton();
player.powerButton();
player.powerButton();
player.volumeDownButton();
player.stopButton();
player.powerButton();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment