Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sasssass
Created June 19, 2020 18:07
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/fbd9e1584eca9a1f5b8dc67a4cab25ef to your computer and use it in GitHub Desktop.
Save sasssass/fbd9e1584eca9a1f5b8dc67a4cab25ef to your computer and use it in GitHub Desktop.
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