TheBulgarianWolf

Lamp

Mar 29th, 2021
1,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.49 KB | None | 0 0
  1. class Lamp{
  2.     private var isOn: Boolean = false;
  3.     fun turnOn(){
  4.         isOn = true;
  5.     }
  6.  
  7.     fun turnOff(){
  8.         isOn = false;
  9.     }
  10.  
  11.     fun displayLightStatus(lamp: String) {
  12.         if (isOn == true)
  13.             println("$lamp lamp is on.")
  14.         else
  15.             println("$lamp lamp is off.")
  16.     }
  17. }
  18.  
  19. fun main(args: Array<String>) {
  20.     var l1 = Lamp()
  21.     var l2 = Lamp()
  22.     l1.turnOn()
  23.  
  24.     l1.displayLightStatus("l1")
  25.     l2.displayLightStatus("l2")
  26. }
Add Comment
Please, Sign In to add comment