Last active
February 28, 2020 09:50
-
-
Save azeezat/a690ef85b08033a31c2cbcfd71110db9 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
class Lamp { | |
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