Skip to content

Instantly share code, notes, and snippets.

@ellehallal
Last active May 29, 2019 07:25
Show Gist options
  • Save ellehallal/d5a213541359a9ca7ee1362ece611705 to your computer and use it in GitHub Desktop.
Save ellehallal/d5a213541359a9ca7ee1362ece611705 to your computer and use it in GitHub Desktop.
public class MusicPlayer implements MediaPlayer{
private String songName;
private boolean isPlaying = false;
public MusicPlayer(String songName) {
this.songName = songName
}
@Override
public void play() {
isPlaying = true;
}
@Override
public void stop() {
isPlaying = false;
}
@Override
public void currentlyPlaying() {
if (isPlaying) {
System.out.println(songName + " is currently playing.");
}
else {
System.out.println("Nothing is playing.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment