private void addNewVehicle()
        {
            string licensePlate = getLicensePlate();
            bool   ifVhicleAlredyExist;

            ifVhicleAlredyExist = m_Garage.CheckIfVhicleAlredyExist(licensePlate);
            if (ifVhicleAlredyExist == true)
            {
                m_UserInterface.Print("Vehicle alredy exist in the garage");
                m_Garage.UpdateStatus(licensePlate, GarageLogic.AutomobileRepairShop.eVehicleStatus.InRepair);
            }
            else
            {
                string vehicleModelName;
                string wheelManufacturer;
                string ownerName;
                string ownerPhoneNumber;
                float  currentAirPressure;
                float  currentEnergyAmount;
                m_UserInterface.ScanOwnerDetails(out ownerName, out ownerPhoneNumber);
                CreateVehicles.eVehiclesType vehicleType = m_UserInterface.getVehicle();
                EngineType.eEnergySource     energySource;
                if (vehicleType == CreateVehicles.eVehiclesType.Truck)
                {
                    energySource = EngineType.eEnergySource.Fuel;
                }
                else
                {
                    m_UserInterface.GetEnergySource(out energySource);
                }

                m_UserInterface.ScanVehicleDetails(out vehicleModelName, out wheelManufacturer, out currentAirPressure, out currentEnergyAmount);
                Vehicle newVehicle = null;
                switch (vehicleType)
                {
                case CreateVehicles.eVehiclesType.Car:
                    newVehicle = CreateVehicles.CreateVehicle(licensePlate, vehicleModelName, wheelManufacturer, energySource, vehicleType, currentAirPressure, currentEnergyAmount);
                    m_UserInterface.GetCarParametrs(newVehicle);
                    break;

                case CreateVehicles.eVehiclesType.Motorcycle:
                    newVehicle = CreateVehicles.CreateVehicle(licensePlate, vehicleModelName, wheelManufacturer, energySource, vehicleType, currentAirPressure, currentEnergyAmount);
                    m_UserInterface.GetMotorcycleParametrs(newVehicle);
                    break;

                case CreateVehicles.eVehiclesType.Truck:
                    newVehicle = CreateVehicles.CreateVehicle(licensePlate, vehicleModelName, wheelManufacturer, energySource, vehicleType, currentAirPressure, currentEnergyAmount);
                    m_UserInterface.GetTruckParametrs(newVehicle);
                    break;
                }

                m_Garage.AddNewVhicle(ownerName, ownerPhoneNumber, newVehicle);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Factory example with and without static object creator
        /// </summary>
        static void FactoryExample()
        {
            VehicleFactory factory = new ConcereteVehicleFactory();
            IFactory       scooter = factory.CreateVehicle <Scooter>();

            scooter.Drive(45);

            IFactory bike = factory.CreateVehicle <Bike>();

            bike.Drive(60);

            IFactory scooter1 = CreateVehicles.CreateVehicle <Scooter>();

            scooter1.Drive(45);

            IFactory bike1 = CreateVehicles.CreateVehicle <Bike>();

            bike1.Drive(70);
        }
Esempio n. 3
0
        private Vehicle getNewVehicleInfo()
        {
            Vehicle        newVehicle;
            eTypeOfVehicle typeOfVehicle;
            string         licenseNumber;

            getVehiliceType(out typeOfVehicle);
            getLicenseNumber(out licenseNumber);
            if (m_GarageSystem.IsInGarageAndChangeToInRepairIfNecessary(licenseNumber))
            {
                throw new Exception(string.Format(
                                        "The vehicle is already in garage!{0}The vehicle status has changed to 'In repair'",
                                        Environment.NewLine));
            }

            newVehicle = CreateVehicles.CreateVehicle(typeOfVehicle, licenseNumber);
            Console.WriteLine("Please enter the following details: ");
            printMessageAndGetValuesForAllTypeVehicle(newVehicle);
            printMessageAndGetValuesForSpecificTypeVehicle(newVehicle);

            return(newVehicle);
        }