Пример #1
0
        /// <summary>
        /// Getting user choice for car doors by a numbered list of the options to choose from.
        /// User will choose 1-4 out of four possible doors amount per car.
        /// </summary>
        /// <returns>Returns the car number of doors after logical check up for amount presents as an optional number from the list</returns>
        internal static Car.e_NumberOfDoors NumberOfCarDoorsInput()
        {
            string carStringNumberOfDoors = string.Empty;
            int    carIntNumberOfDoors    = int.MinValue;

            Car.e_NumberOfDoors numberOfCarDoors = Car.e_NumberOfDoors.Five;
            carStringNumberOfDoors = string.Format(
                @"Number of Doors:
1) Two
2) Three
3) Four
4) Five");
            Console.WriteLine(carStringNumberOfDoors);
            carIntNumberOfDoors = UserChoiceForRangeCheck(GlobalConstants.lowerRangeOfVehicleEnumChoice, GlobalConstants.upperRangeOfVehicleEnumChoice);
            numberOfCarDoors    = (Car.e_NumberOfDoors)Enum.ToObject(typeof(Car.e_NumberOfDoors), carIntNumberOfDoors);
            return(numberOfCarDoors);
        }
Пример #2
0
        /// <summary>
        /// "sub" method helps confirm logical (range and argument) input by while loop for input.
        /// </summary>
        /// <param name="o_carColor">car colour for motorcycle to set inside method (out argument)</param>
        /// <param name="o_numberOfDoors">number of doors for cars to set inside method (out argument)</param>
        internal void CarColourAndNumbersOfDoorsTryCatch(out Car.e_Color o_carColor, out Car.e_NumberOfDoors o_numberOfDoors)
        {
            bool allGoodPerValueCheck = false;

            o_carColor      = Car.e_Color.Black;
            o_numberOfDoors = Car.e_NumberOfDoors.Four;

            while (allGoodPerValueCheck == false)
            {
                try
                {
                    o_carColor           = ConsoleUI.CarColorInput();
                    allGoodPerValueCheck = true;
                }
                catch (ValueOutOfRangeException valueOutOfRangeException)
                {
                    Console.WriteLine(valueOutOfRangeException.Message);
                }
                catch (FormatException formatException)
                {
                    Console.WriteLine(formatException.Message);
                }
            }

            allGoodPerValueCheck = false;
            while (allGoodPerValueCheck == false)
            {
                try
                {
                    o_numberOfDoors      = ConsoleUI.NumberOfCarDoorsInput();
                    allGoodPerValueCheck = true;
                }
                catch (ValueOutOfRangeException valueOutOfRangeException)
                {
                    Console.WriteLine(valueOutOfRangeException.Message);
                }
                catch (FormatException formatException)
                {
                    Console.WriteLine(formatException.Message);
                }
            }
        }
Пример #3
0
        public static Vehicle CreateRegularCar(Vehicle.BasicInformationOfVehicleAndOwner informationOfVehicleAndOwner, Car.e_Color i_color, Car.e_NumberOfDoors i_numberOfDoors)
        {
            Vehicle regularCar = new RegularCar(
                informationOfVehicleAndOwner.m_ModelName,
                informationOfVehicleAndOwner.m_LicenseNumber,
                informationOfVehicleAndOwner.m_WheelManufacturer,
                informationOfVehicleAndOwner.m_CurrentAirPressure,
                informationOfVehicleAndOwner.m_AmountEnergyResource,
                i_color,
                i_numberOfDoors);

            return(regularCar);
        }