Ejemplo n.º 1
0
        public static void Main()
        {
            var carTokens   = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
            var truckTokens = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);

            var carStartQuantity = double.Parse(carTokens[1]);
            var carConsumption   = double.Parse(carTokens[2]);

            var truckStartQuantity = double.Parse(truckTokens[1]);
            var truckConsumption   = double.Parse(truckTokens[2]);

            Vehicle car   = new Car(carStartQuantity, carConsumption);
            Vehicle truck = new Truck(truckStartQuantity, truckConsumption);

            var inputLines = int.Parse(Console.ReadLine());

            for (int i = 0; i < inputLines; i++)
            {
                var    tokens         = Console.ReadLine().Split();
                double distanceOrFuel = double.Parse(tokens[2]);

                if (tokens[1] == "Car")
                {
                    Action(car, tokens[0], distanceOrFuel);
                }
                else
                {
                    Action(truck, tokens[0], distanceOrFuel);
                }
            }
            Print(car.ToString());
            Print(truck.ToString());
        }
Ejemplo n.º 2
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]);

            Car car = new Car(carFuelQuantity, carFuelConsumption);

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

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

            Truck truck = new Truck(truckFuelQuantity, truckFuelConsumption);

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

            for (int i = 0; i < count; i++)
            {
                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
                    {
                        Console.WriteLine(truck.Drive(distance));
                    }
                }
                else if (command == "Refuel")
                {
                    double fuel = double.Parse(commandItems[2]);

                    if (type == "Car")
                    {
                        car.Refuel(fuel);
                    }
                    else
                    {
                        truck.Refuel(fuel);
                    }
                }
            }

            Console.WriteLine(car.ToString());
            Console.WriteLine(truck.ToString());
        }
        public void Run()
        {
            Car   car   = CreateCar();
            Truck truck = CreateTruck();

            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];

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

                        if (vechicleType == "Car")
                        {
                            Console.WriteLine(car.Drive(distance));
                        }
                        else if (vechicleType == "Truck")
                        {
                            Console.WriteLine(truck.Drive(distance));
                        }
                        break;

                    case "Refuel":
                        double fuelAmount = double.Parse(commandArgs[2]);

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

            Console.WriteLine(car.ToString());
            Console.WriteLine(truck.ToString());
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            string[] carInfo   = Console.ReadLine().Split();
            string[] truckInfo = Console.ReadLine().Split();
            string[] busInfo   = Console.ReadLine().Split();
            int      n         = int.Parse(Console.ReadLine());

            Vehicle car   = new Car(double.Parse(carInfo[1]), double.Parse(carInfo[2]), double.Parse(carInfo[3]));
            Vehicle truck = new Truck(double.Parse(truckInfo[1]), double.Parse(truckInfo[2]), double.Parse(truckInfo[3]));
            Vehicle bus   = new Truck(double.Parse(busInfo[1]), double.Parse(busInfo[2]), double.Parse(busInfo[3]));

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

                string command = input[0];
                string vehicle = input[1];

                double distanceOrLitters = double.Parse(input[2]);

                switch (command)
                {
                case "Drive":
                    Console.WriteLine(vehicle == "Car"
                            ? car.Drive(distanceOrLitters)
                            : truck.Drive(distanceOrLitters));
                    break;

                case "Refuel":
                    switch (vehicle)
                    {
                    case "Car":
                        car.Refuel(distanceOrLitters);
                        break;

                    case "Truck":
                        truck.Refuel(distanceOrLitters);
                        break;

                    default:
                        break;
                    }
                    break;

                default:
                    break;
                }
            }


            Console.WriteLine(car.ToString());
            Console.WriteLine(truck.ToString());
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var carInfo   = Console.ReadLine().Split();
            var truckInfo = Console.ReadLine().Split();
            var busInfo   = Console.ReadLine().Split();

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

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

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

            IVehicle car   = new Car(carFuelQuantity, carConsumption, carTankCapacity);
            IVehicle truck = new Truck(truckFuelQuantity, truckConsumption, truckTankCapacity);
            IVehicle bus   = new Bus(busFuelQuantity, busConsumption, busTankCapacity);

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

            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split();

                var value = double.Parse(input[2]);

                switch (input[1])
                {
                case "Car":
                    Action(car, input[0], value);
                    break;

                case "Truck":
                    Action(truck, input[0], value);
                    break;

                case "Bus":
                    Action(bus, input[0], value);
                    break;
                }
            }

            Print(car.ToString());
            Print(truck.ToString());
            Print(bus.ToString());
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            string [] carInfo   = Console.ReadLine().Split(' ');
            string [] truckInfo = Console.ReadLine().Split(' ');

            IVehicle car   = new Car(double.Parse(carInfo[1]), double.Parse(carInfo[2]));
            IVehicle truck = new Truck(double.Parse(truckInfo[1]), double.Parse(truckInfo[2]));

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

            for (int i = 0; i < number; i++)
            {
                string [] command = Console.ReadLine().Split(' ');

                if (command[0] == "Drive")
                {
                    if (command[1] == "Car")
                    {
                        car.Drive(double.Parse(command[2]));
                    }
                    else if (command[1] == "Truck")
                    {
                        truck.Drive(double.Parse(command[2]));
                    }
                }
                else if (command[0] == "Refuel")
                {
                    if (command[1] == "Car")
                    {
                        car.Refuel(double.Parse(command[2]));
                    }
                    else if (command[1] == "Truck")
                    {
                        truck.Refuel(double.Parse(command[2]));
                    }
                }
            }

            Console.WriteLine(car.ToString());
            Console.WriteLine(truck.ToString());
        }
Ejemplo n.º 7
0
        public static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(" ");
            Vehicle  car  = new Car(double.Parse(data[1]), double.Parse(data[2]));

            data = Console.ReadLine().Split(" ");
            Vehicle truck = new Truck(double.Parse(data[1]), double.Parse(data[2]));

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

            for (int i = 0; i < count; i++)
            {
                data = Console.ReadLine().Split(" ");
                string operation = data[0] + data[1];
                double value     = double.Parse(data[2]);
                switch (operation)
                {
                case "DriveCar":
                    Console.WriteLine(car.Drive(value));
                    break;

                case "DriveTruck":
                    Console.WriteLine(truck.Drive(value));
                    break;

                case "RefuelCar":
                    car.Refuel(value);
                    break;

                case "RefuelTruck":
                    truck.Refuel(value);
                    break;

                default:
                    break;
                }
            }

            Console.WriteLine(car.ToString());
            Console.WriteLine(truck.ToString());
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            string[] inputCar = Console.ReadLine().Split();
            Car      car      = new Car(double.Parse(inputCar[1]), double.Parse(inputCar[2]));

            string[] inputTruck = Console.ReadLine().Split();
            Truck    truck      = new Truck(double.Parse(inputTruck[1]), double.Parse(inputTruck[2]));

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

            for (int i = 0; i < numberOfCommands; i++)
            {
                string[] commands       = Console.ReadLine().Split();
                string   currentCommand = commands[0] + " " + commands[1];
                double   currentNum     = double.Parse(commands[2]);

                if (currentCommand == "Drive Car")
                {
                    Console.WriteLine(car.Driving(currentNum));
                }
                else if (currentCommand == "Drive Truck")
                {
                    Console.WriteLine(truck.Driving(currentNum));
                }
                else if (currentCommand == "Refuel Car")
                {
                    car.Refuel(currentNum);
                }
                else if (currentCommand == "Refuel Truck")
                {
                    truck.Refuel(currentNum);
                }
            }

            Console.WriteLine(car.ToString());
            Console.WriteLine(truck.ToString());
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            var carInfo         = Console.ReadLine().Split();
            var fuelQuantity    = double.Parse(carInfo[1]);
            var fuelConsumption = double.Parse(carInfo[2]);
            var tankCapacity    = double.Parse(carInfo[3]);
            var car             = new Car(tankCapacity, fuelQuantity, fuelConsumption);

            var truckInfo = Console.ReadLine().Split();

            fuelQuantity    = double.Parse(truckInfo[1]);
            fuelConsumption = double.Parse(truckInfo[2]);
            tankCapacity    = double.Parse(truckInfo[3]);
            var truck = new Truck(tankCapacity, fuelQuantity, fuelConsumption);

            var busInfo = Console.ReadLine().Split();

            fuelQuantity    = double.Parse(busInfo[1]);
            fuelConsumption = double.Parse(busInfo[2]);
            tankCapacity    = double.Parse(busInfo[3]);
            var bus = new Bus(tankCapacity, fuelQuantity, fuelConsumption);

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

            for (int i = 0; i < count; i++)
            {
                var commandData = Console.ReadLine().Split();
                var command     = commandData[0];
                var vehicleType = commandData[1];
                if (command == "Drive")
                {
                    var distance = double.Parse(commandData[2]);
                    if (vehicleType == "Car")
                    {
                        Console.WriteLine(car.Drive(0.9, distance, vehicleType));
                    }
                    else if (vehicleType == "Truck")
                    {
                        Console.WriteLine(truck.Drive(1.6, distance, vehicleType));
                    }
                    else
                    {
                        Console.WriteLine(bus.Drive(1.4, distance, vehicleType));
                    }
                }
                else if (command == "DriveEmpty")
                {
                    var distance = double.Parse(commandData[2]);
                    Console.WriteLine(bus.Drive(0.0, distance, vehicleType));
                }
                else
                {
                    try
                    {
                        var fuelToAdd = double.Parse(commandData[2]);
                        if (vehicleType == "Car")
                        {
                            try
                            {
                                car.Refuel(fuelToAdd);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                            }
                        }
                        else if (vehicleType == "Truck")
                        {
                            try
                            {
                                truck.Refuel(fuelToAdd);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                            }
                        }
                        else
                        {
                            try
                            {
                                bus.Refuel(fuelToAdd);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }

            Console.WriteLine(car.ToString());
            Console.WriteLine(truck.ToString());
            Console.WriteLine(bus.ToString());
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            var carDetails   = Console.ReadLine().Split();
            var truckDetails = Console.ReadLine().Split();
            var busDetails   = Console.ReadLine().Split();

            var car   = new Car(double.Parse(carDetails[1]), double.Parse(carDetails[2]), double.Parse(carDetails[3]));
            var truck = new Truck(double.Parse(truckDetails[1]), double.Parse(truckDetails[2]), double.Parse(truckDetails[3]));
            var bus   = new Bus(double.Parse(busDetails[1]), double.Parse(busDetails[2]), double.Parse(busDetails[3]));

            var commands = int.Parse(Console.ReadLine());

            for (int i = 0; i < commands; i++)
            {
                var command     = Console.ReadLine().Split();
                var vehicleType = command[1];
                try
                {
                    if (command[0] == "Drive")
                    {
                        var distance = double.Parse(command[2]);
                        if (vehicleType == "Car")
                        {
                            Console.WriteLine(car.Drive(distance));
                        }
                        else if (vehicleType == "Truck")
                        {
                            Console.WriteLine(truck.Drive(distance));
                        }
                        else if (vehicleType == "Bus")
                        {
                            Console.WriteLine(bus.Drive(distance));
                        }
                    }
                    else if (command[0] == "Refuel")
                    {
                        var fuel = double.Parse(command[2]);
                        if (vehicleType == "Car")
                        {
                            car.Refuel(fuel);
                        }
                        else if (vehicleType == "Truck")
                        {
                            truck.Refuel(fuel);
                        }
                        else if (vehicleType == "Bus")
                        {
                            bus.Refuel(fuel);
                        }
                    }
                    else if (command[0] == "DriveEmpty")
                    {
                        var distance = double.Parse(command[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());
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            var    carData         = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
            double fuelQuantity    = double.Parse(carData[1]);
            double fuelConsumption = double.Parse(carData[2]);
            double tankCapacity    = double.Parse(carData[3]);
            Car    car             = new Car(fuelQuantity, fuelConsumption, tankCapacity);

            var truckData = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);

            fuelQuantity    = double.Parse(truckData[1]);
            fuelConsumption = double.Parse(truckData[2]);
            tankCapacity    = double.Parse(truckData[3]);
            Truck truck = new Truck(fuelQuantity, fuelConsumption, tankCapacity);

            var busData = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);

            fuelQuantity    = double.Parse(busData[1]);
            fuelConsumption = double.Parse(busData[2]);
            tankCapacity    = double.Parse(busData[3]);
            Bus bus = new Bus(fuelQuantity, fuelConsumption, tankCapacity);

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

            for (int i = 0; i < num; i++)
            {
                var    cmd     = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
                string command = cmd[0];

                if (command == "Drive")
                {
                    string type = cmd[1];
                    double km   = double.Parse(cmd[2]);

                    if (type == "Car")
                    {
                        car.Drive(km);
                    }
                    else if (type == "Truck")
                    {
                        truck.Drive(km);
                    }
                    else if (type == "Bus")
                    {
                        bus.Drive(km);
                    }
                }
                else if (command == "DriveEmpty")
                {
                    string type = cmd[1];
                    double km   = double.Parse(cmd[2]);
                    if (type == "Bus")
                    {
                        bus.DriveEmpty(km);
                    }
                }
                else if (command == "Refuel")
                {
                    string type    = cmd[1];
                    double litters = double.Parse(cmd[2]);

                    if (type == "Car")
                    {
                        car.Refuel(litters);
                    }
                    else if (type == "Truck")
                    {
                        truck.Refuel(litters);
                    }
                    else if (type == "Bus")
                    {
                        bus.Refuel(litters);
                    }
                }
            }

            //Console.WriteLine($"Car: {car.FuelQuantity:F2}");
            //Console.WriteLine($"Truck: {truck.FuelQuantity:F2}");
            //Console.WriteLine($"");

            Console.WriteLine(car.ToString());
            Console.WriteLine(truck.ToString());
            Console.WriteLine(bus.ToString());
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            string[] carInput   = ReadInfoFromConsole();
            string[] truckInput = ReadInfoFromConsole();
            string[] busInput   = ReadInfoFromConsole();

            Car   car   = (Car)CreateVehicle(carInput);
            Truck truck = (Truck)CreateVehicle(truckInput);
            Bus   bus   = (Bus)CreateVehicle(busInput);

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

            while (numberOfCommands > 0)
            {
                try
                {
                    string[] commands      = ReadInfoFromConsole();
                    string   typeOfVehicle = commands[1];
                    string   action        = commands[0];
                    double   number        = double.Parse(commands[2]);

                    switch (typeOfVehicle)
                    {
                    case "Car":

                        if (action == "Drive")
                        {
                            car.Drive(number);
                        }
                        else if (action == "Refuel")
                        {
                            car.Refuel(number);
                        }
                        break;

                    case "Truck":
                        if (action == "Drive")
                        {
                            truck.Drive(number);
                        }
                        else if (action == "Refuel")
                        {
                            truck.Refuel(number);
                        }
                        break;

                    case "Bus":
                        if (action == "DriveEmpty")
                        {
                            bus.TypeOfBus = "empty";
                            bus.Drive(number);
                        }
                        else if (action == "Drive")
                        {
                            bus.Drive(number);
                        }
                        else if (action == "Refuel")
                        {
                            bus.Refuel(number);
                        }
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                numberOfCommands--;
            }

            Console.WriteLine(car.ToString());
            Console.WriteLine(truck.ToString());
            Console.WriteLine(bus.ToString());
        }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            string[] carArgs   = Console.ReadLine().Split();
            string[] truckArgs = Console.ReadLine().Split();
            string[] busArgs   = Console.ReadLine().Split();

            Car   car   = new Car(double.Parse(carArgs[1]), double.Parse(carArgs[2]), double.Parse(carArgs[3]));
            Truck truck = new Truck(double.Parse(truckArgs[1]), double.Parse(truckArgs[2]), double.Parse(truckArgs[3]));
            Bus   bus   = new Bus(double.Parse(busArgs[1]), double.Parse(busArgs[2]), double.Parse(busArgs[3]));

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

            for (int i = 0; i < count; i++)
            {
                string[] input               = Console.ReadLine().Split();
                string   thingToDo           = input[0];
                string   vehicleType         = input[1];
                double   distanceOrFuelQuant = double.Parse(input[2]);

                if (thingToDo == "Drive")
                {
                    switch (vehicleType)
                    {
                    case "Car":
                        car.DriveVehicle(distanceOrFuelQuant);
                        break;

                    case "Truck":
                        truck.DriveVehicle(distanceOrFuelQuant);
                        break;

                    case "Bus":
                        bus.IsFull = true;
                        bus.DriveVehicle(distanceOrFuelQuant);
                        break;
                    }
                }

                if (thingToDo == "DriveEmpty")
                {
                    bus.IsFull = false;
                    bus.DriveVehicle(distanceOrFuelQuant);
                }

                if (thingToDo == "Refuel")
                {
                    switch (vehicleType)
                    {
                    case "Car":
                        car.RefuelVehicle(distanceOrFuelQuant);
                        break;

                    case "Truck":
                        truck.RefuelVehicle(distanceOrFuelQuant);
                        break;

                    case "Bus":
                        bus.RefuelVehicle(distanceOrFuelQuant);
                        break;
                    }
                }
            }
            Console.WriteLine(car.ToString());
            Console.WriteLine(truck.ToString());
            Console.WriteLine(bus.ToString());
        }
Ejemplo n.º 14
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());
        }
Ejemplo n.º 15
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());
        }