public void Commands(char[] commands) { foreach (var cmd in commands) { ICommand command; if (cmd.Equals('f')) { command = new CommandForward(this); } if (cmd.Equals('b')) { command = new CommandBackwards(this); } if (cmd.Equals('l')) { command = new CommandLeft(this); } if (cmd.Equals('r')) { command = new CommandRight(this); } command.Execute(); } }
protected virtual void OnCommandLeft(CommandEventArgs e) { CommandLeft?.Invoke(this, e); }