Пример #1
0
        private static float GetCarMileageStats(int choice)
        {
            var mpgInfo = 0f;

            switch (choice)
            {
            case 1:
                GasUI gas = new GasUI(new RealConsole());
                mpgInfo = gas.CheckMPG();
                break;

            case 2:
                ElectricUI electric = new ElectricUI(new RealConsole());
                mpgInfo = electric.CheckMPG();
                break;

            case 3:
                HybridUI hybrid = new HybridUI(new RealConsole());
                mpgInfo = hybrid.CheckMPG();
                break;

            default:
                mpgInfo = 0.0f;
                break;
            }

            return(mpgInfo);
        }
Пример #2
0
        private static Cars CreateVehicle(int choice, string make, string model, int year, float numberOfCityMiles,
                                          float numberOfHighwayMiles, float mpgInfo)
        {
            Cars car = new Cars();

            switch (choice)
            {
            case 1:
                var     gasCar = new GasUI(new RealConsole());
                GasCars gas    = gasCar.CreateGas(make, model, year, numberOfCityMiles, numberOfHighwayMiles, mpgInfo);
                gasCar.AddGas(gas);
                car = gas;
                break;

            case 2:
                var          electricCar = new ElectricUI(new RealConsole());
                ElectricCars electric    = electricCar.CreateElectric(make, model, year, numberOfCityMiles,
                                                                      numberOfHighwayMiles, mpgInfo);
                electricCar.AddElectric(electric);
                car = electric;
                break;

            case 3:
                var        hybridCar = new HybridUI(new RealConsole());
                HybridCars hybrid    = hybridCar.CreateHybrid(make, model, year, numberOfCityMiles,
                                                              numberOfHighwayMiles, mpgInfo);
                hybridCar.AddHybrid(hybrid);
                car = hybrid;
                break;

            default:
                break;
            }

            return(car);
        }