Ejemplo n.º 1
0
        /// <summary>
        /// Getting user choice for motorcycle license type by a numbered list of the options to choose from.
        /// User will choose 1-4 out of four possible license types exists.
        /// </summary>
        /// <returns>Returns the motorcycle license type after logical check up for type presents as an optional license from the list</returns>
        internal static Motorcycle.e_LicenseType LicenseTypeInput()
        {
            string licenseStringType = string.Empty;
            int    licenseIntType    = int.MinValue;

            Motorcycle.e_LicenseType licenseType = Motorcycle.e_LicenseType.A;
            licenseStringType = string.Format(
                @"License Type:
1) A
2) A1
3) AA
4) B1");
            Console.WriteLine(licenseStringType);
            licenseIntType = UserChoiceForRangeCheck(GlobalConstants.lowerRangeOfVehicleEnumChoice, GlobalConstants.upperRangeOfVehicleEnumChoice);
            licenseType    = (Motorcycle.e_LicenseType)Enum.ToObject(typeof(Motorcycle.e_LicenseType), licenseIntType);
            return(licenseType);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// "sub" method helps confirm logical (range and argument) input by while loop for input.
        /// </summary>
        /// <param name="o_licenseType">license type for motorcycle to set inside method (out argument)</param>
        /// <param name="o_engineCapacity">engine capacity to set inside method (out argument)</param>
        internal void InputInformationToCreateNewSpecificVehicleCase4(out Motorcycle.e_LicenseType o_licenseType, out int o_engineCapacity)
        {
            bool allGoodPerValueCheck = false;

            o_engineCapacity = int.MinValue;
            o_licenseType    = Motorcycle.e_LicenseType.A;

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

            allGoodPerValueCheck = false;
            while (allGoodPerValueCheck == false)
            {
                try
                {
                    o_licenseType        = ConsoleUI.LicenseTypeInput();
                    allGoodPerValueCheck = true;
                }
                catch (ValueOutOfRangeException valueOutOfRangeException)
                {
                    Console.WriteLine(valueOutOfRangeException.Message);
                }
                catch (FormatException formatException)
                {
                    Console.WriteLine(formatException.Message);
                }
            }
        }
Ejemplo n.º 3
0
        public static Vehicle CreateElectricMotorcycle(Vehicle.BasicInformationOfVehicleAndOwner informationOfVehicleAndOwner, Motorcycle.e_LicenseType i_licenseType, int i_engineCapacity)
        {
            Vehicle electricMotorcycle = new ElectricMotorcycle(
                informationOfVehicleAndOwner.m_ModelName,
                informationOfVehicleAndOwner.m_LicenseNumber,
                informationOfVehicleAndOwner.m_WheelManufacturer,
                informationOfVehicleAndOwner.m_CurrentAirPressure,
                informationOfVehicleAndOwner.m_AmountEnergyResource,
                i_engineCapacity,
                i_licenseType);

            return(electricMotorcycle);
        }