예제 #1
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);
        }