public void AddCommand(TimedCommand cmd) { if (commands.Count == 0) { commands.Add(cmd); } else { int pos; for (pos = 0; pos < commands.Count; pos++) { if (cmd.Time < commands[pos].Time) { break; } } if (pos < commands.Count) { commands.Insert(pos, cmd); } else { commands.Add(cmd); } } showCommands(); }
public void Run() { if (commands.Count == 0) { Console.WriteLine("Execution completed"); } else { TimedCommand cmd = commands[0]; commands.RemoveAt(0); cmd.Execute(this); } }