Example #1
0
        private void updateVehicleProperties(int i_TypeOfVehicleFromUser, Vehicle i_NewVehicleToGarage, string i_ManufactureName, float i_WheelsCurrentAirPressure)
        {
            int firstIndex, secondIndex = 0;

            getTwoIndexesOfCommands(i_TypeOfVehicleFromUser, out firstIndex, out secondIndex);

            while (true)
            {
                try
                {
                    Console.WriteLine(m_InputStringsArray[firstIndex]);
                    string firstPropertie = ValidationOfData.GetStringFromUser();
                    Console.WriteLine(m_InputStringsArray[secondIndex]);
                    string secondPropertie = ValidationOfData.GetStringFromUser();
                    i_NewVehicleToGarage.UpdateSpecificPropeties(firstPropertie, secondPropertie);
                    updateEngineProperties(i_NewVehicleToGarage);
                    i_NewVehicleToGarage.UpdateWheels(i_ManufactureName, i_WheelsCurrentAirPressure);
                    return;
                }
                catch (FormatException ex)
                {
                    Console.WriteLine(@"Input invalid due to '{0}'.please enter again:", ex.Message);
                }
                catch (ValueOutOfRangeException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine(@"Wrong input due to {0},please enter again:", ex.Message);
                }
            }
        }
Example #2
0
        private string getLicenseNumberFromUser()
        {
            Console.WriteLine("Please enter the Vehicles license number:");
            string licenseNumberFromUser = ValidationOfData.GetStringFromUser();

            return(licenseNumberFromUser);
        }
Example #3
0
        private void changeStatusOfVehicle(GarageVehicle i_SearchvihicleInGarage)
        {
            Console.WriteLine("Please enter the Vehicles new status you would like to set:");
            eVehicleStatusInGarage statusToUpdate = ValidationOfData.GetStatusOnGarage();

            i_SearchvihicleInGarage.ChangeCarStatus(statusToUpdate);
            Console.WriteLine("The new status is: {0}", statusToUpdate);
        }
Example #4
0
        private void updateEngineProperties(Vehicle i_NewVehicleToGarage)
        {
            i_NewVehicleToGarage.UpdateEngine();
            Console.WriteLine("Please enter the amount of energy left:");
            float energyLeftInEngine = ValidationOfData.GetFloatFromUserWithinRange(i_NewVehicleToGarage.VehicleEngine.MaxAmountOfEnergy, 0);

            i_NewVehicleToGarage.SetEngineCurrentEnergy(energyLeftInEngine);
        }
Example #5
0
        public void ManageGarage()
        {
            string        liencenseIDFromUser     = string.Empty;
            bool          isVehicleInGarage       = false;
            GarageVehicle currentGarageToDealWith = null;

            Console.WriteLine("Welcome to our garage!");
            string firstMenuToPrint = string.Format(
                @"please enter your choice:
1.Enter a new vehicle to the garage.
2.Execute an action on an existing vehicle.
3.Desplay the list of vehicle license numbers.
4.Close the garage.");

            Console.WriteLine(firstMenuToPrint);
            int inputFromUser = ValidationOfData.GetIntFromUserWithinRange(4, 1);

            while (inputFromUser != 4)
            {
                switch (inputFromUser)
                {
                case 1:
                {
                    createNewVehicle();
                    break;
                }

                case 2:
                    liencenseIDFromUser = getLicenseNumberFromUser();
                    isVehicleInGarage   = m_HadarAndKochGarage.GetGarageVehicleFromUser(liencenseIDFromUser, out currentGarageToDealWith);
                    if (isVehicleInGarage)
                    {
                        performActionOnVehicle(currentGarageToDealWith);
                    }
                    else
                    {
                        Console.WriteLine("Vehicle can not be found on our Garage.");
                    }

                    break;

                case 3:
                    displayAllVehiclesLicenseNumber();
                    break;
                }

                Console.WriteLine(firstMenuToPrint);
                inputFromUser = ValidationOfData.GetIntFromUserWithinRange(4, 1);
            }
        }
Example #6
0
        private void createNewVehicle()
        {
            int  EngineType = 1;
            bool isVehicleAlreadtInGarage = false;

            Console.WriteLine("Please enter the license number:");
            string licenseNumber = ValidationOfData.GetStringFromUser();

            isVehicleAlreadtInGarage = m_HadarAndKochGarage.SearchVehicleInGarage(licenseNumber);
            if (!isVehicleAlreadtInGarage)
            {
                Console.WriteLine("Please enter the vehicle model:");
                string vehicleModel       = ValidationOfData.GetStringFromUser();
                string vehicleMenuToPrint = string.Format(
                    @"Please enter the type of vehicle:
1.Car
2.Motorcycle
3.Truck");
                Console.WriteLine(vehicleMenuToPrint);
                int TypeOfVehicleFromUser = ValidationOfData.GetIntFromUserWithinRange(3, 1);
                if (TypeOfVehicleFromUser != 3)
                {
                    string enginMenuToPrint = string.Format(
                        @"Please enter the type of Engine(press the number):
1.Fuel
2.Electric");

                    Console.WriteLine(enginMenuToPrint);
                    EngineType = ValidationOfData.GetIntFromUserWithinRange(2, 1);
                }

                Vehicle newVehicleToGarage = Garage.CreateTheSpecificVehicle(vehicleModel, licenseNumber, TypeOfVehicleFromUser, EngineType);
                Console.WriteLine("Please enter the wheels manufacture name:");
                string manufactureName = ValidationOfData.GetStringFromUser();
                Console.WriteLine("Please enter the wheels current air pressure:");
                float wheelsCurrentAirPressure = ValidationOfData.GetTheAirPressure(newVehicleToGarage);
                updateVehicleProperties(TypeOfVehicleFromUser, newVehicleToGarage, manufactureName, wheelsCurrentAirPressure);
                Console.WriteLine("Please enter your phone number:");
                long phoneNumber = ValidationOfData.GetLongIntFromUser();
                Console.WriteLine("Please enter your name:");
                string ownerName = ValidationOfData.GetStringFromUser();
                m_HadarAndKochGarage.AddVehicleToGarage(newVehicleToGarage, ownerName, phoneNumber, eVehicleStatusInGarage.InProgress);
            }
            else
            {
                Console.WriteLine("Vehicle with the same license number is already in our garage.Please try again.");
            }
        }
Example #7
0
        private void displayAllVehiclesLicenseNumber()
        {
            bool isStatusNeeded = false;

            Console.WriteLine("Would you like to filter the vehicles by their status ? - true/false");
            isStatusNeeded = ValidationOfData.GetBoolFromUser();
            if (isStatusNeeded)
            {
                Console.WriteLine("Please enter the Vehicles status you would like to watch - InProgress(1)/Fixed(2)/Paid(3):");
                eVehicleStatusInGarage statusToSearch = ValidationOfData.GetStatusOnGarage();
                displayByStatus(statusToSearch);
            }
            else
            {
                displayAllVehicles();
            }
        }
Example #8
0
        private void fillEnergyOfVehicle(GarageVehicle i_SearchvihicleInGarage, bool i_IsRefuelNeed)
        {
            bool        isSuccesfull = false;
            eFuelType   fuelToRefill;
            eEngineType engineType;

            if (i_IsRefuelNeed)
            {
                Console.WriteLine("Please enter the fuel type you would like to fill in - Soler(1)/Octan95(2)/Octan96(3)/octan98(4) :");
                fuelToRefill = ValidationOfData.GetFuelType();
                engineType   = eEngineType.Fuel;
            }
            else
            {
                fuelToRefill = eFuelType.Electricty;
                engineType   = eEngineType.Electric;
            }

            Console.WriteLine("Please enter how many energy would you like to fill in:");
            float amountOfEnergy = ValidationOfData.GetFloatFromUserWithinRange(i_SearchvihicleInGarage.VehicleInGarage.VehicleEngine.MaxAmountOfEnergy, 0); // to change it to within range

            try
            {
                isSuccesfull = i_SearchvihicleInGarage.FillFuelToMax(i_SearchvihicleInGarage.VehicleInGarage, engineType, fuelToRefill, amountOfEnergy);
            }
            catch (ValueOutOfRangeException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (ArgumentException)
            {
                Console.WriteLine(@"The fuel type entered {0} doesn't match the fuel type required .", fuelToRefill);
            }
            catch (Exception)
            {
                Console.WriteLine(@"The energy type entered {0} doesn't match to the vehicle engine .", fuelToRefill);
            }

            if (isSuccesfull)
            {
                printTheResult(isSuccesfull);
            }
        }
Example #9
0
        private void performActionOnVehicle(GarageVehicle i_CurrentGarageToDealWith)
        {
            string secondMenuToPrint = string.Format(
                @"Choose an option to execute:
1.Change vehicle status.
2.Maximize the air pressure of your vehicle.
3.Powered by fuel your vehicle.
4.Chagre an electric vehicle.
5.Display vechile details by license number.");

            Console.WriteLine(secondMenuToPrint);
            int secondInputFromUSer = ValidationOfData.GetIntFromUserWithinRange(5, 1);

            switch (secondInputFromUSer)
            {
            case 1:
                changeStatusOfVehicle(i_CurrentGarageToDealWith);
                break;

            case 2:
                fillMaxAirOfVehicle(i_CurrentGarageToDealWith);
                break;

            case 3:
                fillEnergyOfVehicle(i_CurrentGarageToDealWith, true);
                break;

            case 4:
                fillEnergyOfVehicle(i_CurrentGarageToDealWith, false);
                break;

            case 5:
                displayFullDetailsOfVehicle(i_CurrentGarageToDealWith);
                break;
            }
        }