private void ProcessCommand(string commandAsString) { if (string.IsNullOrWhiteSpace(commandAsString)) { throw new ArgumentNullException("Command cannot be null or empty."); //Constants } string[] commandAndParams = commandAsString.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray(); int optional = 0; string command = commandAndParams[0]; int id = int.Parse(commandAndParams[1]); switch (command.ToLower()) { case "register": carManager.Register(id, commandAndParams[2], commandAndParams[3], commandAndParams[4] , int.Parse(commandAndParams[5]), int.Parse(commandAndParams[6]), int.Parse(commandAndParams[7]) , int.Parse(commandAndParams[8]), int.Parse(commandAndParams[9])); break; case "check": Console.Write(carManager.Check(id)); break; case "open": if (commandAndParams.Length < 7) { optional = 0; } else { optional = int.Parse(commandAndParams[6]); } carManager.Open(id, commandAndParams[2], int.Parse(commandAndParams[3]), commandAndParams[4], int.Parse(commandAndParams[5]), optional); break; case "participate": carManager.Participate(id, int.Parse(commandAndParams[2])); break; case "start": carManager.Start(id); break; case "park": carManager.Park(id); break; case "unpark": carManager.Unpark(id); break; case "tune": carManager.Tune(id, commandAndParams[2]); break; } }