Created
March 31, 2018 10:03
-
-
Save iamcrypticcoder/1bec1a88617f76eef45bbded60861745 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
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