/// <summary> /// Getting user choice for car colour by a numbered list of the options to choose from. /// User will choose 1-4 out of four possible colours. /// </summary> /// <returns>Returns the car colour after logical check up for colour presents as an optional colour from the list</returns> internal static Car.e_Color CarColorInput() { string carStringColor = string.Empty; int carIntColor = int.MinValue; Car.e_Color carColor = Car.e_Color.Black; carStringColor = string.Format( @"Car color: 1) Red 2) Yellow 3) Black 4) Silver"); Console.WriteLine(carStringColor); carIntColor = UserChoiceForRangeCheck(GlobalConstants.lowerRangeOfVehicleEnumChoice, GlobalConstants.upperRangeOfVehicleEnumChoice); carColor = (Car.e_Color)Enum.ToObject(typeof(Car.e_Color), carIntColor); return(carColor); }
/// <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); } } }
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); }