private void ExecuteCommand(string[] commandArgs) { if (commandArgs[0] == "Drive") { double distance = double.Parse(commandArgs[2]); if (commandArgs[1] == "Car") { try { car.Drive(distance); } catch (Exception ex) { Console.WriteLine(ex.Message); } } else if (commandArgs[1] == "Truck") { try { truck.Drive(distance); } catch (Exception ex) { Console.WriteLine(ex.Message); } } else if (commandArgs[1] == "Bus") { try { bus.Drive(distance); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } else if (commandArgs[0] == "DriveEmpty") { double distance = double.Parse(commandArgs[2]); try { Bus emptyBus = bus as Bus; emptyBus?.DriveEmpty(distance); } catch (Exception ex) { Console.WriteLine(ex.Message); } } else if (commandArgs[0] == "Refuel") { double fuelAmount = double.Parse(commandArgs[2]); try { if (commandArgs[1] == "Car") { car.Refuel(fuelAmount); } else if (commandArgs[1] == "Truck") { truck.Refuel(fuelAmount); } else if (commandArgs[1] == "Bus") { bus.Refuel(fuelAmount); } } catch (Exception exception) { Console.WriteLine(exception.Message); } } }