Exemplo n.º 1
0
        private void getValidColor(out eVehicleColors o_Color)
        {
            bool   parseSucceeded = false;
            string input;

            o_Color = eVehicleColors.None;

            Console.Clear();
            do
            {
                try
                {
                    Console.WriteLine("Please insert your car color from the following options:");
                    MenusPrinter.PrintColorsMenu();
                    input          = Console.ReadLine();
                    o_Color        = CustomConverter.ConvertStringColorToVehicleColor(input);
                    parseSucceeded = true;
                }
                catch (ArgumentException e)
                {
                    Console.WriteLine(e.Message);
                }
            }while (!parseSucceeded);
        }
Exemplo n.º 2
0
        public static Car CreateCar(eEngineTypes i_EngineType, string i_Model, string i_LicenseNumber, int i_NumberOfDoors, eVehicleColors i_Color, string i_WheelManufacturer)
        {
            Engine     newEngine             = null;
            Car        newCar                = null;
            float      energyCapacity        = 0;
            eFuelTypes fuelType              = eFuelTypes.None;
            float      k_WheelMaxAirPressure = 32;
            int        k_AmountOfWheels      = 4;

            switch (i_EngineType)
            {
            case eEngineTypes.ElectricVehicle:
            {
                energyCapacity = 3.2f;
                break;
            }

            case eEngineTypes.FuelVehicle:
            {
                energyCapacity = 45;
                fuelType       = eFuelTypes.Octan98;
                break;
            }
            }

            newEngine           = EngineFactory.CreateEngine(i_EngineType, energyCapacity, fuelType);
            newCar              = new Car(newEngine, i_Model, i_LicenseNumber, i_NumberOfDoors);
            newCar.Wheels       = WheelsFactory.CreateWheels(k_AmountOfWheels, k_WheelMaxAirPressure, i_WheelManufacturer);
            newCar.VehicleColor = i_Color;
            return(newCar);
        }