Skip to content

Instantly share code, notes, and snippets.

@sasssass
Last active June 19, 2020 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sasssass/a8e1146c80aefa74f694e6b14284a2d9 to your computer and use it in GitHub Desktop.
Save sasssass/a8e1146c80aefa74f694e6b14284a2d9 to your computer and use it in GitHub Desktop.
ConcreteCommand.kt
abstract class LightCommandMother (var light: Light) : Command {
var lastStatus : Int = light.color
override fun undo() {
light.color = lastStatus
}
}
class LightBlueCommand (light: Light) : LightCommandMother(light) {
override fun execute() {
light.blue()
}
}
class LightWhiteCommand (light: Light) : LightCommandMother(light) {
override fun execute() {
light.white()
}
}
class LightRedCommand (light: Light) : LightCommandMother(light) {
override fun execute() {
light.red()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment