예제 #1
0
        /// <summary>
        /// Method gets by sub methods all basic information for vehicle
        /// </summary>
        /// <param name="basicInformationOfVehicle">stroes given information in struct at vehicle class</param>
        /// <param name="i_vehicleType">get the specific vehicle type</param>
        internal static void EnterBasicInformationOfVehicle(out Vehicle.BasicInformationOfVehicleAndOwner basicInformationOfVehicle, int i_vehicleType)
        {
            string currentStringInfoToPutInStruct       = string.Empty;
            float  currentAirPressureInfoToPutInStruct  = float.MinValue;
            float  currentEnergyAmountInfoToPutInStruct = float.MinValue;
            bool   isGood = false;

            currentStringInfoToPutInStruct        = ModelNameInput();
            basicInformationOfVehicle.m_ModelName = currentStringInfoToPutInStruct;

            currentStringInfoToPutInStruct            = LicenseNumberInput();
            basicInformationOfVehicle.m_LicenseNumber = currentStringInfoToPutInStruct;

            currentStringInfoToPutInStruct = WheelManufacturerInput();
            basicInformationOfVehicle.m_WheelManufacturer = currentStringInfoToPutInStruct;

            currentStringInfoToPutInStruct        = OwnerNameInput();
            basicInformationOfVehicle.m_OwnerName = currentStringInfoToPutInStruct;

            while (isGood == false)
            {
                try
                {
                    currentStringInfoToPutInStruct = OwnerPhoneInput();
                    isGood = true;
                }
                catch (ValueOutOfRangeException valueOutOfRangeException)
                {
                    Console.WriteLine(valueOutOfRangeException.Message);
                }
            }

            basicInformationOfVehicle.m_OwnerPhone = currentStringInfoToPutInStruct;

            float maximumAirPressureValue = float.MinValue;
            float maximumEnergyValue      = float.MinValue;

            SetMaximumAirPressureAndEnergyValueByVehicleType(i_vehicleType, out maximumAirPressureValue, out maximumEnergyValue);

            Console.WriteLine(string.Format("Current Air Pressure: (Maximum: {0})", maximumAirPressureValue));
            TryCatchForCurrentNumericInformation(out currentAirPressureInfoToPutInStruct, maximumAirPressureValue);

            Console.WriteLine(string.Format("Current Fuel Amount: (Maximum: {0})", maximumEnergyValue));
            TryCatchForCurrentNumericInformation(out currentEnergyAmountInfoToPutInStruct, maximumEnergyValue);

            basicInformationOfVehicle.m_CurrentAirPressure   = currentAirPressureInfoToPutInStruct;
            basicInformationOfVehicle.m_AmountEnergyResource = currentEnergyAmountInfoToPutInStruct;
        }
예제 #2
0
 public Vehicle.BasicInformationOfVehicleAndOwner InputInformationForVehicle(int i_vehicleType)
 {
     Vehicle.BasicInformationOfVehicleAndOwner basicInformationOfVehicleAndOwner = new Vehicle.BasicInformationOfVehicleAndOwner();
     ConsoleUI.EnterBasicInformationOfVehicle(out basicInformationOfVehicleAndOwner, i_vehicleType);
     return(basicInformationOfVehicleAndOwner);
 }
예제 #3
0
        /// <summary>
        /// Method sets all specific details for specific vehicles by swtich cases.
        /// </summary>
        /// <returns>return true for successful input process.</returns>
        public bool InputInformationToCreateNewSpecificVehicle()
        {
            int     vehicleType;
            bool    allGoodForInputEnter        = true;
            bool    isCarringHazardousMaterials = false;
            int     engineCapacity = int.MinValue;
            float   volumeCapacity = float.MinValue;
            Vehicle vehicleToCreate;

            Car.e_Color              color;
            Car.e_NumberOfDoors      numberOfDoors;
            Motorcycle.e_LicenseType licenseType;

            ConsoleUI.DetailingSupportingGarageVehicleTypes();

            try
            {
                vehicleType = ConsoleUI.UserChoiceForRangeCheck(GlobalConstants.lowerRangeOfVehicleChoice, GlobalConstants.upperRangeOfVehicleChoice);
                Vehicle.BasicInformationOfVehicleAndOwner informationOfVehicleAndOwner = InputInformationForVehicle(vehicleType);
                switch (vehicleType)
                {
                case 1:     // RegularCar
                    CarColourAndNumbersOfDoorsTryCatch(out color, out numberOfDoors);
                    vehicleToCreate = VehicleCreator.CreateRegularCar(informationOfVehicleAndOwner, color, numberOfDoors);
                    break;

                case 2:     // ElectricCar
                    CarColourAndNumbersOfDoorsTryCatch(out color, out numberOfDoors);
                    vehicleToCreate = VehicleCreator.CreateElectricCar(informationOfVehicleAndOwner, color, numberOfDoors);
                    break;

                case 3:      // RegularMotorcycle
                    InputInformationToCreateNewSpecificVehicleCase3(out licenseType, out engineCapacity);
                    vehicleToCreate = VehicleCreator.CreateRegularMotorcycle(informationOfVehicleAndOwner, licenseType, engineCapacity);
                    break;

                case 4:      // ElectricMotorcycle
                    InputInformationToCreateNewSpecificVehicleCase4(out licenseType, out engineCapacity);
                    vehicleToCreate = VehicleCreator.CreateElectricMotorcycle(informationOfVehicleAndOwner, licenseType, engineCapacity);
                    break;

                case 5:      // Truck
                default:
                    InputInformationToCreateNewSpecificVehicleCase5(out isCarringHazardousMaterials, out volumeCapacity);
                    vehicleToCreate = VehicleCreator.CreateTruck(informationOfVehicleAndOwner, isCarringHazardousMaterials, volumeCapacity);
                    break;
                }

                m_garage.AddNewVehicleToGarageContentsList(
                    informationOfVehicleAndOwner.m_OwnerName,
                    informationOfVehicleAndOwner.m_OwnerPhone,
                    informationOfVehicleAndOwner.m_LicenseNumber,
                    vehicleToCreate);
            }
            catch (FormatException formatException)
            {
                allGoodForInputEnter = false;
                Console.WriteLine(formatException.Message);
            }

            return(allGoodForInputEnter);
        }