Skip to content

Instantly share code, notes, and snippets.

@iamcrypticcoder
Created March 31, 2018 10:03
Show Gist options
  • Save iamcrypticcoder/1bec1a88617f76eef45bbded60861745 to your computer and use it in GitHub Desktop.
Save iamcrypticcoder/1bec1a88617f76eef45bbded60861745 to your computer and use it in GitHub Desktop.
import Foundation
class CommandExecutor {
var nextCommands = [Command]()
var executedCommands = [Command]()
init() {
}
func addCommand(_ command:Command) -> Void {
nextCommands.append(command)
}
func runCommand() -> Void {
while nextCommands.count > 0 {
let command: Command = nextCommands.removeFirst()
command.execute()
executedCommands.append(command)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment