diff --git a/src/soon/PlayZustand.java b/src/soon/PlayZustand.java new file mode 100644 index 0000000000000000000000000000000000000000..b44a8b26d14527c0150fddf473fb47ad7c041ae7 --- /dev/null +++ b/src/soon/PlayZustand.java @@ -0,0 +1,13 @@ +package soon; + +public class PlayZustand extends Zustand { + + public PlayZustand(Soon s) { + super(s); + } + + public void stopButton() { + s.stopPlay(); + s.setZustand(s.getStopZustand()); + } +} diff --git a/src/soon/Soon.java b/src/soon/Soon.java new file mode 100644 index 0000000000000000000000000000000000000000..b2a2004b76a5b34b56e840f48b86ecd8e9f96220 --- /dev/null +++ b/src/soon/Soon.java @@ -0,0 +1,50 @@ +package soon; + +public class Soon { + Zustand stopZustand; + Zustand playZustand; + + Zustand zustand; + + public Soon () { + stopZustand = new StopZustand(this); + playZustand = new PlayZustand(this); + zustand = stopZustand; + } + + public Zustand getStopZustand() { + return stopZustand; + } + + public Zustand getPlayZustand() { + return playZustand; + } + + public void setZustand(Zustand zustand) { + this.zustand = zustand; + } + + public void playButton() { + zustand.playButton(); + } + + public void stopButton() { + zustand.stopButton(); + } + + public void startPlay() { + System.out.println("Musik an"); + } + + public void stopPlay() { + System.out.println("Musik aus"); + } + + public String toString() { + StringBuffer result = new StringBuffer(); + result.append("\nSoon MP3 Player"); + result.append("\n---------------"); + result.append("\nSoon available soon in MyCross-Platform Software Store\n"); + return result.toString(); + } +} diff --git a/src/soon/SoonTestDrive.java b/src/soon/SoonTestDrive.java new file mode 100644 index 0000000000000000000000000000000000000000..8f377ed89d330f295de879616bc0a19be916a072 --- /dev/null +++ b/src/soon/SoonTestDrive.java @@ -0,0 +1,14 @@ +package soon; + +public class SoonTestDrive { + + public static void main(String[] args) { + + Soon player = new Soon(); + + System.out.println(player); + player.playButton(); + player.stopButton(); + } + +} diff --git a/src/soon/StopZustand.java b/src/soon/StopZustand.java new file mode 100644 index 0000000000000000000000000000000000000000..3210093421488c5182511fe2472dcea0cf4b7264 --- /dev/null +++ b/src/soon/StopZustand.java @@ -0,0 +1,13 @@ +package soon; + +public class StopZustand extends Zustand { + + public StopZustand(Soon s) { + super(s); + } + + public void playButton() { + s.startPlay(); + s.setZustand(s.getPlayZustand()); + } +} diff --git a/src/soon/Zustand.java b/src/soon/Zustand.java new file mode 100644 index 0000000000000000000000000000000000000000..5ff57b1fa17394590ee2e434c5b6137636224db4 --- /dev/null +++ b/src/soon/Zustand.java @@ -0,0 +1,12 @@ +package soon; + +public abstract class Zustand { + protected Soon s; + + public Zustand(Soon s) { + this.s = s; + } + + public void playButton() {}; + public void stopButton() {}; +}