static void Main() { CommandParser cmdParser = new CommandParser(); string[] carInput = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray(); Vehicle car = new Car(double.Parse(carInput[1]), double.Parse(carInput[2])); string[] truckInput = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray(); Vehicle truck = new Truck(double.Parse(truckInput[1]), double.Parse(truckInput[2])); int commands = int.Parse(Console.ReadLine()); for (int i = 1; i <= commands; i++) { string[] command = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray(); switch (command[1]) { case "Car": cmdParser.ExecuteCommand(command, car); break; case "Truck": cmdParser.ExecuteCommand(command, truck); break; } } Console.WriteLine(car.ToString()); Console.WriteLine(truck.ToString()); }
private static void OnClientEventTriggerHandler(Client player, string eventName, object[] args) { switch (eventName) { case "console_client_function_executeCommand": CommandParser.ExecuteCommand(player, (string)args[0]); break; case "console_client_function_enabledConsole": if (enabledConsoleForClient.ContainsKey(player)) { enabledConsoleForClient[player] = (bool)args[0]; } else { enabledConsoleForClient.Add(player, (bool)args[0]); } break; } }
static void Main(string[] args) { if (args.Length > 0 && args[1] == "exec") { CommandParser.ExecuteCommand(args.Skip(1)); return; } while (true) { Console.Write("Enter a command: "); var cmd = Console.ReadLine(); if (cmd == "exit" || cmd == "e") { break; } CommandParser.ExecuteCommand(cmd); } }