Пример #1
0
        private void refeul()
        {
            string customerLicenceNumber = getCustomerLicence();

            Console.WriteLine("Which type of fuel you want refuel? choose from options below:");
            Console.WriteLine(@"1. Soler
2. Octan95
3. Octan96
4. Octan98");
            try
            {
                string answer = Console.ReadLine();
                answer = UIValidation.ValidateChoiceNumberInRange(1, 4, answer);
                Console.WriteLine("How much fuel do you want to fill?");
                string amountOfFuel = Console.ReadLine();
                r_Garage.Refuel(customerLicenceNumber, answer, amountOfFuel);
                Console.WriteLine("Refuled successfully!");
            }
            catch (ArgumentException exception)
            {
                Console.WriteLine(exception.Message);
            }
            catch (ValueOutOfRangeException exception)
            {
                Console.WriteLine(exception.Message);
            }

            Console.ReadLine();
        }
Пример #2
0
        private void displayLicneseNumberListOfAllCarsInGarage()
        {
            Console.WriteLine("Would you like to see specific status of cars? choose from options below:");
            Console.WriteLine(@"1. In repair
2. Fixed and unpaid
3. Fixed and paid
4. All");
            try
            {
                string answer = UIValidation.ValidateChoiceNumberInRange(1, 4, Console.ReadLine());
                string licenseNumbertoDisplay = r_Garage.FilterLicneseNumberByGarageStatus(answer);
                if (licenseNumbertoDisplay.Equals(string.Empty) && answer.Equals("4"))
                {
                    Console.WriteLine("No Cars in the garage at the moment!");
                }
                else if (licenseNumbertoDisplay.Equals(string.Empty))
                {
                    Console.WriteLine("No Cars with this status in the garage at the moment!");
                }
                else
                {
                    Console.WriteLine(licenseNumbertoDisplay);
                }
            }
            catch (ArgumentException exception)
            {
                Console.WriteLine(exception.Message);
            }

            Console.ReadLine();
        }
Пример #3
0
        private void insertNewVehicleToTheGarage()
        {
            bool isValidInput = false;

            while (!isValidInput)
            {
                Console.WriteLine("Please Enter your full Name:");
                string customerFullName = UIValidation.ReadAndValidateNameFormat(Console.ReadLine());
                Console.WriteLine("Please Enter your phone Number:");
                string customerPhoneNumber = UIValidation.ReadValidateNumberSequence(Console.ReadLine(), 10);
                Console.WriteLine("What is the type of your vehicle?");
                Console.WriteLine(@"1.Fuel motorcycle
2.Electric motorcycle
3.Fuel car
4.Electric car
5.Truck");

                int optionNumber = 0;
                isValidInput = true;
                try
                {
                    int numOfVehiclesTypesGarageHandles = Enum.GetNames(typeof(GarageLogic.VehicleGenerator.eVehicleType)).Length;
                    optionNumber = int.Parse(UIValidation.ValidateChoiceNumberInRange(1, numOfVehiclesTypesGarageHandles, Console.ReadLine()));
                    GarageLogic.VehicleGenerator.eVehicleType vehicleType = (GarageLogic.VehicleGenerator.eVehicleType)optionNumber;
                    GarageLogic.VehicleGenerator vehicleGenerator         = new GarageLogic.VehicleGenerator();
                    Dictionary <string, string>  vehicleDictionary        = vehicleGenerator.CreateSuitableVehicleDictionary(vehicleType);
                    updateDictionary(vehicleDictionary);
                    GarageLogic.Vehicle costumerVehicle = vehicleGenerator.CreateNewVehicle(vehicleType, vehicleDictionary);
                    bool isAlreadyInGarage = r_Garage.AddANewVehicle(costumerVehicle, customerFullName, customerPhoneNumber);
                    if (!isAlreadyInGarage)
                    {
                        Console.WriteLine(@"Your vehicle has been added to the garage!");
                    }
                    else
                    {
                        Console.WriteLine(@"Your vehicle already exists in our system.");
                    }
                }
                catch (FormatException exception)
                {
                    Console.WriteLine(exception.Message);
                    isValidInput = false;
                }
                catch (ValueOutOfRangeException exception)
                {
                    Console.WriteLine(exception.Message);
                    isValidInput = false;
                }
                catch (ArgumentException exception)
                {
                    Console.WriteLine(exception.Message);
                    isValidInput = false;
                }

                Console.ReadLine();
                Console.Clear();
            }
        }
Пример #4
0
        public static void EnterNewCarUI(Garage i_MyGarage)
        {
            Vehicle userVehicle = SetNewVehicle();
            bool    validName   = true;
            string  ownerName   = string.Empty;

            Console.WriteLine("please enter your name:");

            while (validName)
            {
                try
                {
                    validName = !true;
                    ownerName = Console.ReadLine();
                    ownerName = UIValidation.UserStringValidation(ownerName);
                }
                catch (FormatException fe)
                {
                    Console.WriteLine(fe.Message);
                    validName = true;
                }
            }

            bool   validPhone  = true;
            string phoneNumber = string.Empty;

            Console.WriteLine("please enter your Phone number:");
            while (validPhone)
            {
                try
                {
                    validPhone  = !true;
                    phoneNumber = Console.ReadLine();
                    UIValidation.IsANumberValidation(phoneNumber);
                }
                catch (FormatException fe)
                {
                    Console.WriteLine(fe.Message);
                    validPhone = true;
                }
            }

            bool carInGarage = i_MyGarage.EnterNewCar(ownerName, phoneNumber, userVehicle);

            if (!carInGarage)
            {
                Console.WriteLine("Your vehicle is already in the garage \n");
            }
            else
            {
                Console.WriteLine("Thank you, now your car is in the garage \n");
            }
        }
Пример #5
0
        public static void FuelVehical(Garage i_MyGarage)
        {
            string userAnswer = string.Empty;
            string licenseNum = GarageUI.AskForLicenseNum();
            bool   validFuel  = !true;
            eFuel  fuelType   = 0;

            Console.WriteLine("Please enter fuel type <Octan98, Octan96, Octan95, Soler>");
            while (!validFuel)
            {
                try
                {
                    validFuel  = true;
                    userAnswer = Console.ReadLine();
                    fuelType   = UIValidation.FuelTypeValidation(userAnswer);
                }
                catch (FormatException fe)
                {
                    Console.WriteLine(fe.Message + "Wrong choise, please select fuel type <Octan98, Octan96, Octan95, Soler> ");
                    validFuel = !true;
                }
            }

            int fuelAmount = 0;

            Console.WriteLine("Please enter fuel amount");
            fuelAmount = GarageUI.AskForAmount();

            try
            {
                bool fuelSucceses = i_MyGarage.FuelingVehicle(licenseNum, fuelType, fuelAmount);
                Console.WriteLine("Fuel success \n");
            }
            catch (ArgumentNullException ane)
            {
                Console.WriteLine("The car is not in the garage \n");
            }
            catch (ArgumentException ax)
            {
                Console.WriteLine(ax.Message + " Fuel faild");
            }
            catch (ValueOutOfRangeException vor)
            {
                Console.WriteLine(vor.Message + " Fuel faild");
            }
        }
Пример #6
0
        public void StartService()
        {
            Console.WriteLine("Welcome to the number one garage service in the world!\n");
            while (m_GarageIsActive)
            {
                Console.WriteLine("Please choose the number of your desired service:\n");
                foreach (KeyValuePair <int, string> service in r_Garage.GarageServices)
                {
                    Console.WriteLine("{0}. {1}", service.Key, service.Value);
                }

                string chosenService = Console.ReadLine();
                chosenService = UIValidation.ValidateChoiceNumberInRange(1, r_Garage.GarageServices.Count, chosenService);
                PerformService(int.Parse(chosenService));
                Console.WriteLine();
                Console.Clear();
            }
        }
Пример #7
0
        private void changingVeichleStatus()
        {
            string customerLicenceNumber = getCustomerLicence();

            Console.WriteLine("Enter your desired status to update. choose from options below:");
            Console.WriteLine(@"1. In repair
2. Fixed and unpaid
3. Fixed and paid");
            try
            {
                string answer = UIValidation.ValidateChoiceNumberInRange(1, 3, Console.ReadLine());
                r_Garage.UpdateVehicleStatus(customerLicenceNumber, answer);
                Console.WriteLine(@"Status updated as your request!");
            }
            catch (ArgumentException exception)
            {
                Console.WriteLine(exception.Message);
            }

            Console.ReadLine();
        }
Пример #8
0
        public static string AskForLicenseNum()
        {
            bool   validLicenseNum = !true;
            string userAnswer      = string.Empty;

            Console.WriteLine("Please enter your license number:");

            while (!validLicenseNum)
            {
                try
                {
                    userAnswer      = Console.ReadLine();
                    validLicenseNum = UIValidation.IsANumberValidation(userAnswer);
                }
                catch (FormatException fe)
                {
                    Console.WriteLine("This is not valid license number, please use only numbers:");
                    validLicenseNum = !true;
                }
            }

            return(userAnswer);
        }
Пример #9
0
        public static int AskForAmount()
        {
            string userAnswer     = string.Empty;
            bool   validAmount    = !true;
            int    amountToCharge = 0;

            while (!validAmount)
            {
                try
                {
                    validAmount    = true;
                    userAnswer     = Console.ReadLine();
                    amountToCharge = UIValidation.EnergyAmount(userAnswer);
                }
                catch (FormatException fe)
                {
                    Console.WriteLine(fe.Message + " Please use only numbers:");
                    validAmount = !true;
                }
            }

            return(amountToCharge);
        }
Пример #10
0
        public static Vehicle SetNewVehicle()
        {
            string vehicle = string.Empty;
            Dictionary <string, string> parametrs = new Dictionary <string, string>();
            string currentWheelPressure           = string.Empty;
            string currentEnergy  = string.Empty;
            string licenseNumber  = string.Empty;
            string typeOfWheel    = string.Empty;
            string modelType      = string.Empty;
            bool   validationFlag = !true;

            System.Console.WriteLine("Hello! Please enter your vehicle type, those are the vehicle we support:");
            int i = 0;

            foreach (eVehicleType type in Enum.GetValues(typeof(eVehicleType)))
            {
                System.Console.WriteLine("* For " + type.ToString() + " Press " + i);
                i++;
            }

            while (!validationFlag)
            {
                try
                {
                    vehicle        = System.Console.ReadLine();
                    validationFlag = Validation.TypeOfVehicle(vehicle);
                }
                catch (ArgumentException e)
                {
                    validationFlag = false;
                    System.Console.WriteLine(e.Message);
                }
            }

            validationFlag = !true;
            parametrs.Add("Vehicle Type", vehicle.ToString());
            Enum.TryParse <eVehicleType>(vehicle, out eVehicleType eVehicle);
            VehicleCreation.AddSpecInfo(eVehicle, parametrs);

            System.Console.WriteLine("Please enter your number of license:");

            while (!validationFlag)
            {
                try
                {
                    licenseNumber  = System.Console.ReadLine();
                    validationFlag = UIValidation.IsANumberValidation(licenseNumber);
                }
                catch (FormatException e)
                {
                    validationFlag = false;
                    System.Console.WriteLine(e.Message);
                }
            }
            validationFlag = !true;
            Console.Clear();
            parametrs.Add("Licence Number", licenseNumber);

            System.Console.WriteLine("Please enter the current pressure in your wheele:");

            while (!validationFlag)
            {
                try
                {
                    parametrs.TryGetValue("Maximal Air Pressure", out string maxAirPressue);
                    validationFlag = Validation.RangeValidation(currentWheelPressure = System.Console.ReadLine(), maxAirPressue);
                }
                catch (ArgumentException e)
                {
                    validationFlag = !true;
                    System.Console.WriteLine(e.Message);
                }
            }

            validationFlag = !true;
            parametrs.Add("Current Wheel Pressure", currentWheelPressure);

            System.Console.WriteLine("Please enter the type of the wheele:");

            while (!validationFlag)
            {
                try
                {
                    typeOfWheel    = UIValidation.UserStringValidation(System.Console.ReadLine());
                    validationFlag = true;
                }
                catch (FormatException e)
                {
                    validationFlag = !true;
                    System.Console.WriteLine(e.Message);
                }
            }

            validationFlag = !true;
            parametrs.Add("Type Of Wheele", typeOfWheel);

            System.Console.WriteLine("Please enter your current amount of eneregy left (Whether it's an" +
                                     " electric or a fuel engine):");

            while (!validationFlag)
            {
                try
                {
                    parametrs.TryGetValue("Engine Capacity", out string engineCapacity);
                    validationFlag = Validation.RangeValidation(currentEnergy = System.Console.ReadLine(), engineCapacity);
                }
                catch (ArgumentException e)
                {
                    validationFlag = !true;
                    System.Console.WriteLine(e.Message);
                }
            }

            validationFlag = !true;
            parametrs.Add("Amount Of Energy Left", currentEnergy);

            System.Console.WriteLine("Please enter the model of your car:");

            while (!validationFlag)
            {
                try
                {
                    modelType      = UIValidation.UserStringValidation(System.Console.ReadLine());
                    validationFlag = true;
                }
                catch (FormatException e)
                {
                    validationFlag = !true;
                    System.Console.WriteLine(e.Message);
                }
            }

            parametrs.Add("Model Type", modelType);
            parametrs = expendVehicleParameter(eVehicle, parametrs);
            VehicleCreation vehicleBuilder = new VehicleCreation(parametrs, eVehicle);
            Vehicle         newVehicle     = vehicleBuilder.vehicle;

            return(newVehicle);
        }
Пример #11
0
        private static string getCustomerLicence()
        {
            Console.WriteLine("Please enter your licence number, 8 digits:");

            return(UIValidation.ReadValidateNumberSequence(Console.ReadLine(), 8));
        }