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

Add start and stop

parent fbf0b49e
No related branches found
No related tags found
No related merge requests found
package soon;
public class PlayZustand extends Zustand {
public PlayZustand(Soon s) {
super(s);
}
public void stopButton() {
s.stopPlay();
s.setZustand(s.getStopZustand());
}
}
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();
}
}
package soon;
public class SoonTestDrive {
public static void main(String[] args) {
Soon player = new Soon();
System.out.println(player);
player.playButton();
player.stopButton();
}
}
package soon;
public class StopZustand extends Zustand {
public StopZustand(Soon s) {
super(s);
}
public void playButton() {
s.startPlay();
s.setZustand(s.getPlayZustand());
}
}
package soon;
public abstract class Zustand {
protected Soon s;
public Zustand(Soon s) {
this.s = s;
}
public void playButton() {};
public void stopButton() {};
}
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