Skip to content

Instantly share code, notes, and snippets.

@singhrahuldps
Last active April 30, 2020 13:56
Show Gist options
  • Save singhrahuldps/279e1dbef75fd792479e1278554d5bf4 to your computer and use it in GitHub Desktop.
Save singhrahuldps/279e1dbef75fd792479e1278554d5bf4 to your computer and use it in GitHub Desktop.
// A Media Player IS A Device
public class MediaPlayer extends Device{
boolean turnedOn;
// In absence of super() statement, java automatically adds one during compilation
public MediaPlayer() {
this.turnedOn = false;
}
@Override
void switchOn() {
System.out.println("Player turned On!");
this.turnedOn = true;
}
@Override
void switchOff() {
System.out.println("Player turned Off!");
this.turnedOn = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment