norangebit d8f4e8bedf
All checks were successful
continuous-integration/drone/tag Build is passing
add drill06
2020-04-21 16:33:19 +02:00

29 lines
563 B
Kotlin

package drills.drill06.exercise4.actuator
interface Action {
enum class State {
ON, OFF
}
fun getActionName(): String
fun getState(): State
fun on()
fun off()
}
abstract class VirtualAction : Action {
private var state = Action.State.OFF
override fun getState(): Action.State = state
override fun off() {
println("Switching off: ${getActionName()}")
state = Action.State.OFF
}
override fun on() {
println("Switching on: ${getActionName()}")
state = Action.State.ON
}
}