Пример #1
0
        private Vehicle CreateVehicle(string inputLine)
        {
            var arr                  = inputLine.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var type                 = arr[0];
            var fuelQuantity         = double.Parse(arr[1]);
            var fuelConsumptionPerKm = double.Parse(arr[2]);
            var fuelTank             = double.Parse(arr[3]);

            if (type == "Car")
            {
                return(CarFactory.CraeteCar(fuelQuantity, fuelConsumptionPerKm, fuelTank));
            }
            else if (type == "Truck")
            {
                return(TruckFactory.CraeteTruck(fuelQuantity, fuelConsumptionPerKm, fuelTank));
            }
            else if (type == "Bus")
            {
                return(BusFactory.CraeteBus(fuelQuantity, fuelConsumptionPerKm, fuelTank));
            }

            throw new ArgumentException();
        }