Example #1
0
        private static Engine getEngineForUser(CreateVwhicleInGarage.eVehicleTypes i_UserVehicleType)
        {
            Engine engineForUser;

            if (i_UserVehicleType != CreateVwhicleInGarage.eVehicleTypes.Truck)
            {
                Engine.eEngineType requestedEngine;

                requestedEngine = getEngineTypeFromUser(k_NumberOfEngineTypes);

                if (requestedEngine == Engine.eEngineType.Fuel)
                {
                    if (i_UserVehicleType == CreateVwhicleInGarage.eVehicleTypes.Motorcycle)
                    {
                        float currentAmountOfFuelLeft = getAmountOfFuelLeftInVeicle(6);
                        float percentOfFuelInVehicle  = (currentAmountOfFuelLeft / 6) * 100;
                        engineForUser = CreateVwhicleInGarage.CreateFuelEngine(FuelEngine.eFuelType.Octan96, currentAmountOfFuelLeft, percentOfFuelInVehicle, 6);
                    }
                    else
                    {
                        float currentAmountOfFuelLeft = getAmountOfFuelLeftInVeicle(45);
                        float percentOfFuelInVehicle  = (currentAmountOfFuelLeft / 45) * 100;
                        engineForUser = CreateVwhicleInGarage.CreateFuelEngine(FuelEngine.eFuelType.Octan98, currentAmountOfFuelLeft, percentOfFuelInVehicle, 45);
                    }
                }
                else
                {
                    if (i_UserVehicleType == CreateVwhicleInGarage.eVehicleTypes.Motorcycle)
                    {
                        float timeLeftInBattery         = getTimeLeftInBattery(1.8f);
                        float percentOfBatteryInVehicle = (timeLeftInBattery / 1.8f) * 100;
                        engineForUser = CreateVwhicleInGarage.CreateElectricEngine(timeLeftInBattery, percentOfBatteryInVehicle, 1.8f);
                    }
                    else
                    {
                        float timeLeftInBattery         = getTimeLeftInBattery(3.2f);
                        float percentOfBatteryInVehicle = (timeLeftInBattery / 3.2f) * 100;
                        engineForUser = CreateVwhicleInGarage.CreateElectricEngine(timeLeftInBattery, percentOfBatteryInVehicle, 3.2f);
                    }
                }
            }
            else
            {
                float currentAmountOfFuelLeft = getAmountOfFuelLeftInVeicle(115);
                float percentOfFuelInVehicle  = (currentAmountOfFuelLeft / 115) * 100;
                engineForUser = CreateVwhicleInGarage.CreateFuelEngine(FuelEngine.eFuelType.Soler, currentAmountOfFuelLeft, percentOfFuelInVehicle, 115);
            }

            return(engineForUser);
        }
Example #2
0
        private static List <Wheel> getWheelsFromUser(Vehicle.eNuberOfWheelsForVehicle i_NumberOfWheelsForVehicle, Vehicle.eMaximumAirPressure i_MaximumAirPressure)
        {
            List <Wheel> VehicleWheels = new List <Wheel>();
            string       manufacturerName;
            float        currentAirPressure;
            Wheel        wheelForVehicle;

            for (int i = 1; i <= (int)i_NumberOfWheelsForVehicle; i++)
            {
                Console.WriteLine("enter wheel number {0} information", i);
                manufacturerName   = getWheelManufacturerName();
                currentAirPressure = getcurrentAirPressure((float)i_MaximumAirPressure);
                wheelForVehicle    = CreateVwhicleInGarage.CreateWheel(manufacturerName, currentAirPressure, (int)i_MaximumAirPressure);
                VehicleWheels.Add(wheelForVehicle);
            }

            return(VehicleWheels);
        }
Example #3
0
        private static void registerVehicle(string i_VehicleLicensePlate, Garage i_Garage)
        {
            string stringUserChoiceForVehicle;
            int    intUserChoiceForVehicle = 0;
            bool   isChoiceValid           = !true;

            CreateVwhicleInGarage.eVehicleTypes typeOfVehicleToAdd;
            string          vehicleOwnersName        = getVehicleOwnersName();
            string          vehicleOwnersPhoneNumber = getVehicleOwnersPhoneNumber();
            string          vehicleModelName         = getVehicleModelName();
            Engine          engineForVehicle;
            List <Wheel>    wheelsForVehicle;
            Vehicle         vehicleToAdd = null;
            VehicleInGarage newVehicleToAddToTheGarage;

            while (isChoiceValid == !true)
            {
                printVehicleMenu();
                stringUserChoiceForVehicle = Console.ReadLine();
                try
                {
                    intUserChoiceForVehicle = convertUserChoiceToInt(stringUserChoiceForVehicle);
                    isChoiceValid           = checkChoiceValidity(intUserChoiceForVehicle, 1, k_NumberOfVehicleTypes);
                }
                catch (FormatException)
                {
                    Console.WriteLine("Invalid input! bad format");
                }
            }

            typeOfVehicleToAdd = (CreateVwhicleInGarage.eVehicleTypes)intUserChoiceForVehicle;

            switch (typeOfVehicleToAdd)
            {
            case CreateVwhicleInGarage.eVehicleTypes.Motorcycle:
                engineForVehicle = getEngineForUser(CreateVwhicleInGarage.eVehicleTypes.Motorcycle);
                wheelsForVehicle = getWheelsFromUser(Vehicle.eNuberOfWheelsForVehicle.TwoWheels, Vehicle.eMaximumAirPressure.MotorcycleAirPressure);
                Motorcycle.eLicenseType licenseType = getLicenseTypeFromUser();
                int engineVolume = getEngineVolumeFromUser();
                vehicleToAdd = CreateVwhicleInGarage.CreateMotorcycle(licenseType, engineVolume, vehicleModelName, i_VehicleLicensePlate, Vehicle.eMaximumAirPressure.MotorcycleAirPressure, wheelsForVehicle, engineForVehicle);
                break;

            case CreateVwhicleInGarage.eVehicleTypes.Car:
                engineForVehicle = getEngineForUser(CreateVwhicleInGarage.eVehicleTypes.Car);
                wheelsForVehicle = getWheelsFromUser(Vehicle.eNuberOfWheelsForVehicle.FourWheels, Vehicle.eMaximumAirPressure.CarAirPressure);
                Car.eNumbersOfDoors numberOfDoors = getNumberOfDoorsInCar();
                Car.eColor          carColor      = getCarColor();
                vehicleToAdd = CreateVwhicleInGarage.CreateCar(carColor, numberOfDoors, vehicleModelName, i_VehicleLicensePlate, Vehicle.eMaximumAirPressure.CarAirPressure, wheelsForVehicle, engineForVehicle);
                break;

            case CreateVwhicleInGarage.eVehicleTypes.Truck:
                engineForVehicle = getEngineForUser(CreateVwhicleInGarage.eVehicleTypes.Truck);
                wheelsForVehicle = getWheelsFromUser(Vehicle.eNuberOfWheelsForVehicle.TwelveWheels, Vehicle.eMaximumAirPressure.TruckAirPressure);
                bool  isTrunkCooled = askUserIfTruckTrunkCooled();
                float trunkVolume   = getTruckTrunkVolumeFromUser();
                vehicleToAdd = CreateVwhicleInGarage.CreateTruck(isTrunkCooled, trunkVolume, vehicleModelName, i_VehicleLicensePlate, Vehicle.eMaximumAirPressure.TruckAirPressure, wheelsForVehicle, engineForVehicle);
                break;
            }

            newVehicleToAddToTheGarage = CreateVwhicleInGarage.RegisterVehicleIntoGarage(vehicleOwnersName, vehicleOwnersPhoneNumber, vehicleToAdd);
            i_Garage.AddVehicleToTheGarageList(newVehicleToAddToTheGarage);
            Console.WriteLine("Vehicle added successfully");
        }