示例#1
1
        static void Main(string[] args)
        {
            string[] inputCar = Console.ReadLine().Split(new[] { ' ', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            double fuelCar = double.Parse(inputCar[1]);
            double litresCar = double.Parse(inputCar[2]);
            double tankCar = double.Parse(inputCar[3]);
            var car = new Car(fuelCar, litresCar,tankCar);

            string[] inputTruck = Console.ReadLine().Split(new[] { ' ', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            double fuelTruck = double.Parse(inputTruck[1]);
            double litresTruck = double.Parse(inputTruck[2]);
            double tankTruck = double.Parse(inputTruck[3]);
            var truck = new Truck(fuelTruck, litresTruck,tankTruck);

            string[] inputBus = Console.ReadLine().Split(new[] { ' ', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            double fuelBus = double.Parse(inputBus[1]);
            double litresBus = double.Parse(inputBus[2]);
            double tankBus = double.Parse(inputBus[3]);
            var bus = new Bus(fuelBus, litresBus, tankBus);
            int number = int.Parse(Console.ReadLine());
            for (int i = 0; i < number; i++)
            {
                string[] input = Console.ReadLine().Split(new[] { ' ', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                string command = input[0];
                string machine = input[1];
                double distance = double.Parse(input[2]);
                if (command=="Drive")
                {
                    if (machine=="Car")
                    {
                        car.Drive(distance);
                    }
                    else if(machine=="Truck")
                    {
                        truck.Drive(distance);
                    }
                    else
                    {
                        bus.Drive(distance);
                    }
                }
                else if(command=="Refuel")
                {
                    if (machine=="Car")
                    {
                        car.Refuel(distance);
                    }
                    else if(machine=="Truck")
                    {
                        truck.Refuel(distance);
                    }
                    else
                    {
                        bus.Refuel(distance);
                    }
                }
                else
                {
                    bus.ConditionOf();
                    bus.Drive(distance);
                }
            }
            Console.WriteLine($"Car: {car.Fuel:F2}");
            Console.WriteLine($"Truck: {truck.Fuel:F2}");
            Console.WriteLine($"Bus: {bus.Fuel:F2}");
        }
示例#2
0
        static void Main(string[] args)
        {
           // var carinput = Console.ReadLine().Split(' ');
           // var fuelAmount = double.Parse(carinput[1]);
           // var fuelConsumption = double.Parse(carinput[2]);
           // var tankCapacity = ParseTankCapacity(fuelAmount,double.Parse(carinput[3]));
           // IVehicle car = new Car(fuelAmount, fuelConsumption, tankCapacity);
           //
           // var truckInput = Console.ReadLine().Split(' ');
           // fuelAmount = double.Parse(truckInput[1]);
           // fuelConsumption = double.Parse(truckInput[2]);
           // tankCapacity = ParseTankCapacity(fuelAmount,double.Parse(truckInput[3]));
           // IVehicle truck = new Truck(fuelAmount, fuelConsumption,tankCapacity);
           //
           // var busInput = Console.ReadLine().Split(' ');
           // fuelAmount = double.Parse(busInput[1]);
           // fuelConsumption = double.Parse(busInput[2]);
           // tankCapacity = ParseTankCapacity(fuelAmount, double.Parse(busInput[3]));
           // Bus bus = new Bus(fuelAmount, fuelConsumption, tankCapacity);

            List<IVehicle> vehicles = new List<IVehicle>();
            for(int i = 0; i < 3; i++)
            {
                var inputTokens = Console.ReadLine().Split();
                var vehicleType = inputTokens[0];
                var passedFuel = double.Parse(inputTokens[1]);
                var vehicleConsumption = double.Parse(inputTokens[2]);
                var vehicleTankCapacity = double.Parse(inputTokens[3]);
                var vehicleFuel = ParseFuel(passedFuel, vehicleTankCapacity);
                IVehicle vehicle=null;
                switch (vehicleType)
                {
                    case "Car":
                        vehicle = new Car(vehicleFuel, vehicleConsumption, vehicleTankCapacity);
                        break;
                    case "Truck":
                        vehicle = new Truck(vehicleFuel, vehicleConsumption, vehicleTankCapacity);
                        break;
                    case "Bus":
                        vehicle = new Bus(vehicleFuel, vehicleConsumption, vehicleTankCapacity);
                        break;
                }

                vehicles.Add(vehicle);
            }

            var totalInputs = int.Parse(Console.ReadLine());
            Car car = (Car)vehicles.Find(v => v.GetType().Name == "Car");
            Truck truck = (Truck)vehicles.Find(v => v.GetType().Name == "Truck");
            Bus bus = (Bus)vehicles.Find(v => v.GetType().Name == "Bus");
            for (int i = 0; i< totalInputs; i++)
            {
                var inputLine = Console.ReadLine();
                var inputTokens = inputLine.Split(' ');
                var command = inputTokens[0];
                var vehicle = inputTokens[1];
                var distanceOrAmount = double.Parse(inputTokens[2]);
                if(command == "Refuel" && distanceOrAmount <= 0)
                {
                    Console.WriteLine("Fuel must be a positive number");
                    continue;
                }
                switch (command)
                {
                    case "Drive":
                        if(vehicle == "Car")
                        {
                            car.Drive(distanceOrAmount);
                        }
                        else if(vehicle == "Truck")
                        {
                            truck.Drive(distanceOrAmount);
                        }
                        else if(vehicle == "Bus")
                        {
                            bus.Drive(distanceOrAmount);
                        }
                        break;

                    case "Refuel":
                        if(vehicle == "Car")
                        {
                            car.Refuel(distanceOrAmount);
                        }
                        else if(vehicle == "Truck")
                        {
                            truck.Refuel(distanceOrAmount);
                        }
                        else if(vehicle == "Bus")
                        {
                            bus.Refuel(distanceOrAmount);
                        }
                        break;
                    case "DriveEmpty":
                        bus.DriveEmpty(distanceOrAmount);
                        break;
                }

            }
            
            foreach(var vehicle in vehicles)
            {
                Console.WriteLine(vehicle);
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            Car   car   = null;
            Truck truck = null;
            Bus   bus   = null;

            for (int i = 0; i < 3; i++)
            {
                string[] vehicleInfo = Console.ReadLine().Split();
                if (vehicleInfo[0] == "Car")
                {
                    double vehicleFuelQuantity    = double.Parse(vehicleInfo[1]);
                    double vehicleFuelConsumption = double.Parse(vehicleInfo[2]);
                    double tankCapacity           = double.Parse(vehicleInfo[3]);
                    car = new Car(vehicleFuelQuantity, vehicleFuelConsumption, tankCapacity);
                }
                else if (vehicleInfo[0] == "Bus")
                {
                    double vehicleFuelQuantity    = double.Parse(vehicleInfo[1]);
                    double vehicleFuelConsumption = double.Parse(vehicleInfo[2]);
                    double tankCapacity           = double.Parse(vehicleInfo[3]);
                    bus = new Bus(vehicleFuelQuantity, vehicleFuelConsumption, tankCapacity);
                }
                else
                {
                    double vehicleFuelQuantity    = double.Parse(vehicleInfo[1]);
                    double vehicleFuelConsumption = double.Parse(vehicleInfo[2]);
                    double tankCapacity           = double.Parse(vehicleInfo[3]);
                    truck = new Truck(vehicleFuelQuantity, vehicleFuelConsumption, tankCapacity);
                }
            }
            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string[] cmdArgs = Console.ReadLine().Split();
                string   action  = cmdArgs[0];
                string   vehicle = cmdArgs[1];
                if (action == "Drive" && vehicle == "Car")
                {
                    double distance = double.Parse(cmdArgs[2]);
                    car.Drive(distance);
                }
                else if (action == "Drive" && vehicle == "Truck")
                {
                    double distance = double.Parse(cmdArgs[2]);
                    truck.Drive(distance);
                }
                else if (action == "Refuel" && vehicle == "Car")
                {
                    double liters = double.Parse(cmdArgs[2]);
                    car.Refuel(liters);
                }
                else if (action == "Refuel" && vehicle == "Truck")
                {
                    double liters = double.Parse(cmdArgs[2]);
                    truck.Refuel(liters);
                }
                else if (action == "Drive" && vehicle == "Bus")
                {
                    double distance = double.Parse(cmdArgs[2]);
                    bus.Drive(distance);
                }
                else if (action == "DriveEmpty" && vehicle == "Bus")
                {
                    double distance = double.Parse(cmdArgs[2]);
                    bus.DriveEmpty(distance);
                }
                else if (action == "Refuel" && vehicle == "Bus")
                {
                    double liters = double.Parse(cmdArgs[2]);
                    bus.Refuel(liters);
                }
            }
            Console.WriteLine(car);
            Console.WriteLine(truck);
            Console.WriteLine(bus);
        }
示例#4
0
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
            Car car   = new Car(double.Parse(input[1]), double.Parse(input[2]), double.Parse(input[3]));

            input = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
            Truck truck = new Truck(double.Parse(input[1]), double.Parse(input[2]), double.Parse(input[3]));

            input = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
            Bus bus      = new Bus(double.Parse(input[1]), double.Parse(input[2]), double.Parse(input[3]));
            var commands = int.Parse(Console.ReadLine());

            for (int i = 0; i < commands; i++)
            {
                var tokens = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
                try
                {
                    if (tokens[0] == "Drive")
                    {
                        var distance = double.Parse(tokens[2]);
                        if (tokens[1] == "Car")
                        {
                            Console.WriteLine(car.Drive(distance));
                        }
                        else if (tokens[1] == "Truck")
                        {
                            Console.WriteLine(truck.Drive(distance));
                        }
                        else
                        {
                            Console.WriteLine(bus.Drive(distance));
                        }
                    }
                    else if (tokens[0] == "Refuel")
                    {
                        var fuelAmount = double.Parse(tokens[2]);
                        if (tokens[1] == "Car")
                        {
                            car.Refuel(fuelAmount);
                        }
                        else if (tokens[1] == "Truck")
                        {
                            truck.Refuel(fuelAmount);
                        }
                        else
                        {
                            bus.Refuel(fuelAmount);
                        }
                    }
                    else
                    {
                        var distance = double.Parse(tokens[2]);
                        Console.WriteLine(bus.DriveEmpty(distance));
                    }
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine(ex.Message.ToString());
                }
            }
            Console.WriteLine(car.ToString());
            Console.WriteLine(truck.ToString());
            Console.WriteLine(bus.ToString());
        }
示例#5
0
        static void Main()
        {
            string[] carInfo   = Console.ReadLine().Split();
            string[] truckInfo = Console.ReadLine().Split();
            string[] busInfo   = Console.ReadLine().Split();

            int count = int.Parse(Console.ReadLine());

            double carFuel          = double.Parse(carInfo[1]);
            double carConsumption   = double.Parse(carInfo[2]);
            double carTank          = double.Parse(carInfo[3]);
            double truckFuel        = double.Parse(truckInfo[1]);
            double truckConsumption = double.Parse(truckInfo[2]);
            double truckTank        = double.Parse(truckInfo[3]);
            double busFuel          = double.Parse(busInfo[1]);
            double busConsumption   = double.Parse(busInfo[2]);
            double busTank          = double.Parse(busInfo[3]);

            Car   car   = new Car(carFuel, carConsumption, carTank);
            Truck truck = new Truck(truckFuel, truckConsumption, truckTank);
            Bus   bus   = new Bus(busFuel, busConsumption, busTank);

            for (int i = 0; i < count; i++)
            {
                string[] commandLine = Console.ReadLine().Split();

                string command = commandLine[0];
                string type    = commandLine[1];

                switch (type)
                {
                case "Car":

                    if (command == "Drive")
                    {
                        double distance = double.Parse(commandLine[2]);

                        Console.WriteLine(car.Drive(distance));
                    }

                    else if (command == "Refuel")
                    {
                        double fuel = double.Parse(commandLine[2]);

                        car.Refuel(fuel);
                    }

                    break;

                case "Truck":

                    if (command == "Drive")
                    {
                        double distance = double.Parse(commandLine[2]);

                        Console.WriteLine(truck.Drive(distance));
                    }

                    else if (command == "Refuel")
                    {
                        double fuel = double.Parse(commandLine[2]);

                        truck.Refuel(fuel);
                    }

                    break;

                case "Bus":

                    if (command == "Drive")
                    {
                        double distance = double.Parse(commandLine[2]);

                        Console.WriteLine(bus.Drive(distance));
                    }

                    else if (command == "Refuel")
                    {
                        double fuel = double.Parse(commandLine[2]);

                        bus.Refuel(fuel);
                    }

                    else if (command == "DriveEmpty")
                    {
                        double distance = double.Parse(commandLine[2]);
                        Console.WriteLine(bus.DriveEmpty(distance));
                    }
                    break;
                }
            }

            Console.WriteLine(car);
            Console.WriteLine(truck);
            Console.WriteLine(bus);
        }
        public void Run()
        {
            string[] carInfo = Console.ReadLine()
                               .Split()
                               .ToArray();

            string[] truckInfo = Console.ReadLine()
                                 .Split()
                                 .ToArray();

            string[] busInfo = Console.ReadLine()
                               .Split()
                               .ToArray();

            double carFuelQuantity    = double.Parse(carInfo[1]);
            double carFuelConsumption = double.Parse(carInfo[2]);
            double carTankCapacity    = double.Parse(carInfo[3]);

            double truckFuelQuantity = double.Parse(truckInfo[1]);
            double truckConsumption  = double.Parse(truckInfo[2]);
            double truckTankCapacity = double.Parse(truckInfo[3]);

            double busFuelQuantity    = double.Parse(busInfo[1]);
            double busFuelConsumption = double.Parse(busInfo[2]);
            double busTankCapacity    = double.Parse(busInfo[3]);


            var car   = new Car(carFuelQuantity, carFuelConsumption, carTankCapacity);
            var truck = new Truck(truckFuelQuantity, truckConsumption, truckTankCapacity);
            var bus   = new Bus(busFuelQuantity, busFuelConsumption, busTankCapacity);

            int count = int.Parse(Console.ReadLine());

            for (int i = 0; i < count; i++)
            {
                try
                {
                    string[] inputInfo = Console.ReadLine()
                                         .Split()
                                         .ToArray();

                    string command     = inputInfo[0];
                    string vehicleType = inputInfo[1];
                    double value       = double.Parse(inputInfo[2]);

                    if (command == "Drive")
                    {
                        if (vehicleType == "Car")
                        {
                            DriveVehicle(car, value);
                        }

                        else if (vehicleType == "Truck")
                        {
                            DriveVehicle(truck, value);
                        }

                        else if (vehicleType == "Bus")
                        {
                            bus.IsEmpty = false;
                            DriveVehicle(bus, value);
                        }
                    }

                    else if (command == "Refuel")
                    {
                        if (vehicleType == "Car")
                        {
                            car.Refuel(value);
                        }
                        else if (vehicleType == "Truck")
                        {
                            truck.Refuel(value);
                        }
                        else if (vehicleType == "Bus")
                        {
                            bus.Refuel(value);
                        }
                    }

                    else if (command == "DriveEmpty")
                    {
                        bus.IsEmpty = true;
                        DriveVehicle(bus, value);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            Console.WriteLine($"Car: {Math.Round(car.FuelQuantity, 2, MidpointRounding.ToEven):F2}");
            Console.WriteLine($"Truck: {Math.Round(truck.FuelQuantity, 2, MidpointRounding.ToEven):F2}");
            Console.WriteLine($"Bus: {Math.Round(bus.FuelQuantity, 2, MidpointRounding.ToEven):F2}");
        }
        public void Run()
        {
            Car   car   = CreateCar();
            Truck truck = CreateTruck();
            Bus   bus   = CreateBus();

            int commandsCount = int.Parse(Console.ReadLine());

            for (int i = 0; i < commandsCount; i++)
            {
                try
                {
                    string[] commandArgs = Console.ReadLine()
                                           .Split(" ", StringSplitOptions.RemoveEmptyEntries);

                    string command      = commandArgs[0];
                    string vechicleType = commandArgs[1];

                    if (command == "Drive")
                    {
                        double distance = double.Parse(commandArgs[2]);

                        if (vechicleType == "Car")
                        {
                            Console.WriteLine(car.Drive(distance));
                        }
                        else if (vechicleType == "Truck")
                        {
                            Console.WriteLine(truck.Drive(distance));
                        }
                        else if (vechicleType == "Bus")
                        {
                            Console.WriteLine(bus.Drive(distance));
                        }
                    }
                    else if (command == "DriveEmpty")
                    {
                        double distance = double.Parse(commandArgs[2]);
                        Console.WriteLine(bus.DriveEmpty(distance));
                    }
                    else if (command == "Refuel")
                    {
                        double fuelAmount = double.Parse(commandArgs[2]);

                        if (vechicleType == "Car")
                        {
                            car.Refuel(fuelAmount);
                        }
                        else if (vechicleType == "Truck")
                        {
                            truck.Refuel(fuelAmount);
                        }
                        else if (vechicleType == "Bus")
                        {
                            bus.Refuel(fuelAmount);
                        }
                    }
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                    continue;
                }
            }

            Console.WriteLine(car.ToString());
            Console.WriteLine(truck.ToString());
            Console.WriteLine(bus.ToString());
        }
示例#8
0
        static void Main(string[] args)
        {
            string[] carInfo = Console.ReadLine()
                               .Split()
                               .ToArray();
            string[] truckInfo = Console.ReadLine()
                                 .Split()
                                 .ToArray();
            string[] busInfo = Console.ReadLine()
                               .Split()
                               .ToArray();

            double carFuelQuantity    = double.Parse(carInfo[1]);
            double carFuelConsumption = double.Parse(carInfo[2]);
            double carTankCapacity    = double.Parse(carInfo[3]);

            double truckFuelQuantity    = double.Parse(truckInfo[1]);
            double truckFuelConsumption = double.Parse(truckInfo[2]);
            double truckTankCapacity    = double.Parse(truckInfo[3]);

            double busFuelQuantity    = double.Parse(busInfo[1]);
            double busFuelConsumption = double.Parse(busInfo[2]);
            double busTankCapacity    = double.Parse(busInfo[3]);

            Car   car   = new Car(carFuelQuantity, carFuelConsumption, carTankCapacity);
            Truck truck = new Truck(truckFuelQuantity, truckFuelConsumption, truckTankCapacity);
            Bus   bus   = new Bus(busFuelQuantity, busFuelConsumption, busTankCapacity);


            int countLines = int.Parse(Console.ReadLine());

            for (int i = 0; i < countLines; i++)
            {
                try
                {
                    string[] line = Console.ReadLine()
                                    .Split()
                                    .ToArray();
                    string command     = line[0];
                    string vehicleType = line[1];
                    double value       = double.Parse(line[2]);

                    if (command == "Drive")
                    {
                        if (vehicleType == "Car")
                        {
                            DriveVehicle(car, value);
                        }
                        else if (vehicleType == "Truck")
                        {
                            DriveVehicle(truck, value);
                        }
                        else if (vehicleType == "Bus")
                        {
                            bus.isEmpty = false;
                            DriveVehicle(bus, value);
                        }
                    }
                    else if (command == "Refuel")
                    {
                        if (vehicleType == "Car")
                        {
                            car.Refuel(value);
                        }
                        else if (vehicleType == "Truck")
                        {
                            truck.Refuel(value);
                        }
                        else if (vehicleType == "Bus")
                        {
                            bus.Refuel(value);
                        }
                    }
                    else if (command == "DriveEmpty")
                    {
                        bus.isEmpty = true;
                        DriveVehicle(bus, value);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            Console.WriteLine($"Car: {car.FuelQuantity:F2}");
            Console.WriteLine($"Truck: {truck.FuelQuantity:F2}");
            Console.WriteLine($"Bus: {bus.FuelQuantity:F2}");
        }
示例#9
0
        static void Main(string[] args)
        {
            string[] carInput = Console.ReadLine()
                                .Split(" ", StringSplitOptions.RemoveEmptyEntries);
            string[] truckInput = Console.ReadLine()
                                  .Split(" ", StringSplitOptions.RemoveEmptyEntries);
            string[] busInput = Console.ReadLine()
                                .Split(" ", StringSplitOptions.RemoveEmptyEntries);
            Car   car   = new Car(double.Parse(carInput[1]), double.Parse(carInput[2]), double.Parse(carInput[3]));
            Truck truck = new Truck(double.Parse(truckInput[1]), double.Parse(truckInput[2]), double.Parse(truckInput[3]));
            Bus   bus   = new Bus(double.Parse(busInput[1]), double.Parse(busInput[2]), double.Parse(busInput[3]));

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine()
                                 .Split(" ", StringSplitOptions.RemoveEmptyEntries);
                string command = input[0];
                string type    = input[1];
                double amount  = double.Parse(input[2]);

                if (command == "Drive")
                {
                    if (type == "Car")
                    {
                        Drive(car, amount);
                    }
                    else if (type == "Truck")
                    {
                        Drive(truck, amount);
                    }
                    else if (type == "Bus")
                    {
                        bus.isEmpty = false;
                        Drive(bus, amount);
                    }
                }
                else if (command == "Refuel")
                {
                    try
                    {
                        if (type == "Car")
                        {
                            car.Refuel(amount);
                        }
                        else if (type == "Truck")
                        {
                            truck.Refuel(amount);
                        }
                        else if (type == "Bus")
                        {
                            bus.Refuel(amount);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                else if (command == "DriveEmpty")
                {
                    bus.isEmpty = true;
                    Drive(bus, amount);
                }
            }

            Console.WriteLine($"Car: {car.Quantity:f2}");
            Console.WriteLine($"Truck: {truck.Quantity:f2}");
            Console.WriteLine($"Bus: {bus.Quantity:f2}");
        }
示例#10
0
        private static void Main()
        {
            string[] carItems = Console.ReadLine()
                                .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            double carFuelQuantity    = double.Parse(carItems[1]);
            double carFuelConsumption = double.Parse(carItems[2]);
            double carTankCapacity    = double.Parse(carItems[3]);

            Car car = new Car(carFuelQuantity, carFuelConsumption, carTankCapacity);

            string[] truckItems = Console.ReadLine()
                                  .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            double truckFuelQuantity    = double.Parse(truckItems[1]);
            double truckFuelConsumption = double.Parse(truckItems[2]);
            double truckTankCapacity    = double.Parse(truckItems[3]);

            Truck truck = new Truck(truckFuelQuantity, truckFuelConsumption, truckTankCapacity);

            string[] busItems = Console.ReadLine()
                                .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            double busFuelQuantity    = double.Parse(busItems[1]);
            double busFuelConsumption = double.Parse(busItems[2]);
            double busTankCapacity    = double.Parse(busItems[3]);

            Bus bus = new Bus(busFuelQuantity, busFuelConsumption, busTankCapacity);

            int count = int.Parse(Console.ReadLine());

            for (int i = 0; i < count; i++)
            {
                try
                {
                    string[] commandItems = Console.ReadLine()
                                            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                    string command = commandItems[0];
                    string type    = commandItems[1];

                    if (command == "Drive")
                    {
                        double distance = double.Parse(commandItems[2]);

                        if (type == "Car")
                        {
                            Console.WriteLine(car.Drive(distance));
                        }
                        else if (type == "Truck")
                        {
                            Console.WriteLine(truck.Drive(distance));
                        }
                        else if (type == "Bus")
                        {
                            Console.WriteLine(bus.Drive(distance));
                        }
                    }
                    else if (command == "Refuel")
                    {
                        double fuel = double.Parse(commandItems[2]);

                        if (type == "Car")
                        {
                            car.Refuel(fuel);
                        }
                        else if (type == "Truck")
                        {
                            truck.Refuel(fuel);
                        }
                        else if (type == "Bus")
                        {
                            bus.Refuel(fuel);
                        }
                    }
                    else if (command == "DriveEmpty")
                    {
                        double distance = double.Parse(commandItems[2]);
                        Console.WriteLine(bus.DriveEmpty(distance));
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            Console.WriteLine(car.ToString());
            Console.WriteLine(truck.ToString());
            Console.WriteLine(bus.ToString());
        }