Exemplo n.º 1
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();
            }
        }
Exemplo n.º 2
0
        private static string getCustomerLicence()
        {
            Console.WriteLine("Please enter your licence number, 8 digits:");

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