Created
June 19, 2020 18:07
-
-
Save sasssass/fbd9e1584eca9a1f5b8dc67a4cab25ef 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 RemoteControl { | |
private val commandStack: Stack<Command> = Stack() | |
fun pressButton(command: Command) { | |
command.execute() | |
commandStack.push(command) | |
} | |
fun undoButton(){ | |
if(!commandStack.isEmpty()){ | |
val lastCommand = commandStack.pop() | |
lastCommand.undo() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment