Last active
February 28, 2020 20:42
-
-
Save azeezat/a0fe49954271be167734362b9ce8f42e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface LampInterface{ | |
void turnOn(); | |
void turnOff(); | |
displayLightStatus() | |
} | |
class Lamp implements LampInterface{ | |
boolean isOn; | |
void turnOn() { | |
isOn = true; | |
} | |
void turnOff() { | |
isOn = false; | |
} | |
void displayLightStatus() { | |
System.out.println("Light on? " + isOn); | |
} | |
} | |
class ClassObjectsExample { | |
public static void main(String[] args) { | |
Lamp l1 = new Lamp(); | |
Lamp l2 = new Lamp(); | |
l1.turnOn(); | |
l2.turnOff(); | |
l1.displayLightStatus(); | |
l2.displayLightStatus(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment