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 { ...@@ -7,7 +7,8 @@ public class PowerOff extends Zustand {
} }
public void powerButton() { public void powerButton() {
s.setZustand(s.getStopZustand()); exit();
s.setZustand(s.getPowerOnHistory());
System.out.println("Anschalten"); System.out.println("Anschalten");
} s.getZustand().entry(); }
} }
...@@ -7,6 +7,8 @@ public abstract class PowerOn extends Zustand { ...@@ -7,6 +7,8 @@ public abstract class PowerOn extends Zustand {
} }
public void powerButton() { public void powerButton() {
exit();
s.setPowerOnHistory(s.getZustand());
s.setZustand(s.getPowerOffZustand()); s.setZustand(s.getPowerOffZustand());
System.out.println("Ausschalten"); System.out.println("Ausschalten");
} }
......
...@@ -4,6 +4,7 @@ public class Soon { ...@@ -4,6 +4,7 @@ public class Soon {
Zustand stopZustand; Zustand stopZustand;
Zustand playZustand; Zustand playZustand;
Zustand powerOffZustand; Zustand powerOffZustand;
Zustand powerOnHistory;
Zustand zustand; Zustand zustand;
...@@ -12,6 +13,7 @@ public class Soon { ...@@ -12,6 +13,7 @@ public class Soon {
playZustand = new PlayZustand(this); playZustand = new PlayZustand(this);
powerOffZustand = new PowerOff(this); powerOffZustand = new PowerOff(this);
zustand = powerOffZustand; zustand = powerOffZustand;
powerOnHistory = stopZustand;
} }
public Zustand getPowerOffZustand() { public Zustand getPowerOffZustand() {
...@@ -69,6 +71,14 @@ public class Soon { ...@@ -69,6 +71,14 @@ public class Soon {
public void volumeDown() { public void volumeDown() {
System.out.println("Leiser"); System.out.println("Leiser");
} }
public Zustand getPowerOnHistory() {
return powerOnHistory;
}
public void setPowerOnHistory(Zustand z) {
powerOnHistory = z;
}
public String toString() { public String toString() {
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
......
...@@ -10,6 +10,8 @@ public class SoonTestDrive { ...@@ -10,6 +10,8 @@ public class SoonTestDrive {
player.powerButton(); player.powerButton();
player.playButton(); player.playButton();
player.volumeUpButton(); player.volumeUpButton();
player.powerButton();
player.powerButton();
player.volumeDownButton(); player.volumeDownButton();
player.stopButton(); player.stopButton();
player.powerButton(); 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