Example #1
0
        private void changeVehicleStateOp()
        {
            string           requestedLicenseNumber;
            string           input;
            eVehicleStatuses status;

            getValidLicenseNumber(out requestedLicenseNumber);
            Console.Clear();
            try
            {
                Console.WriteLine("Please choose the status you would like to set:");
                MenusPrinter.PrintVehicleStatuses();
                input  = Console.ReadLine();
                status = CustomConverter.ConvertStringToVehicleStatus(input);
                m_GarageManager.ChangeVehicleStatus(requestedLicenseNumber, status);
                Console.WriteLine("Successfuly changed status for vehicle with license number:{0}", requestedLicenseNumber);
            }
            catch (FormatException e)
            {
                Console.WriteLine(string.Format("Error has occured!{0}{1}", Environment.NewLine, e.Message));
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(string.Format("Error has occured!{0}{1}", Environment.NewLine, e.Message));
            }
            catch (ValueOutOfRangeException e)
            {
                Console.WriteLine(string.Format("Error has occured!{0}{1}", Environment.NewLine, e.Message));
            }
        }
Example #2
0
        private void showLicenceNumbersOp()
        {
            string           input;
            eVehicleStatuses choice;
            bool             parseSucceeded;

            Console.Clear();
            do
            {
                try
                {
                    parseSucceeded = true;
                    Console.WriteLine("Please choose which license numbers you would like to see according to the following filters:");
                    MenusPrinter.PrintStatusFilterMenu();
                    input  = Console.ReadLine();
                    choice = CustomConverter.ConvertStringToVehicleStatusFiltering(input);
                    printLicenseNumbersByVehiclesState(choice);
                }
                catch (FormatException e)
                {
                    parseSucceeded = false;
                    Console.WriteLine(e.Message);
                }
                catch (ArgumentException e)
                {
                    parseSucceeded = false;
                    Console.WriteLine(e.Message);
                }
            }while (!parseSucceeded);
        }
Example #3
0
        private void getLicenseType(out eLicenseTypes o_LicenseType)
        {
            string input;
            bool   parseSucceeded = false;

            o_LicenseType = eLicenseTypes.None;

            Console.Clear();
            do
            {
                try
                {
                    Console.WriteLine("Please insert your license type by typing one of the following options:");
                    MenusPrinter.PrintLicenseTypesMenu();
                    input          = Console.ReadLine();
                    o_LicenseType  = CustomConverter.ConvertStringToLicenseType(input);
                    parseSucceeded = true;
                }
                catch (FormatException e)
                {
                    Console.WriteLine(e.Message);
                    parseSucceeded = false;
                }
                catch (ArgumentException e)
                {
                    Console.WriteLine(e.Message);
                    parseSucceeded = false;
                }
            }while (!parseSucceeded);
        }
Example #4
0
        private Vehicle getDataForCreateNewVehicle(string i_LicenseNumber)
        {
            eVehicleTypeOptions vehicleTypeChoice;
            bool    parseSucceeded = false;
            Vehicle vehicle        = null;
            string  input;

            Console.Clear();
            do
            {
                try
                {
                    MenusPrinter.PrintVehicleTypeOptions();
                    input             = Console.ReadLine();
                    vehicleTypeChoice = CustomConverter.ConvertInputToVehicleTypeOption(input);
                    vehicle           = getDataByVehicleTypeChoice(vehicleTypeChoice, i_LicenseNumber);
                    parseSucceeded    = true;
                }
                catch (FormatException e)
                {
                    Console.WriteLine(e.Message);
                    parseSucceeded = false;
                }
                catch (ArgumentException e)
                {
                    Console.WriteLine(e.Message);
                    parseSucceeded = false;
                }
            }while (!parseSucceeded);

            return(vehicle);
        }
Example #5
0
        public void Run()
        {
            eMainMenuOptions mainMenuChoice = eMainMenuOptions.InvalidChoice;

            do
            {
                MenusPrinter.PrintMainMenu();
                mainMenuChoice = getUserChoice();
                doActionUserByMainMenuChoice(mainMenuChoice);
            }while (mainMenuChoice != eMainMenuOptions.ExitProgram);
        }
Example #6
0
        private eFuelTypes getFuelTypeToFill()
        {
            eFuelTypes fuelType = eFuelTypes.None;
            int        choice;
            bool       isValid;

            Console.Clear();
            do
            {
                try
                {
                    Console.WriteLine("Please choose the requested fuel type:");
                    MenusPrinter.PrintFuelTypesMenu();
                    isValid = int.TryParse(Console.ReadLine(), out choice);
                    if (!isValid)
                    {
                        throw new FormatException("Invalid choice. Input must be a number");
                    }
                    else if (!Enum.IsDefined(typeof(eFuelTypes), choice) || (eFuelTypes)choice == eFuelTypes.None)
                    {
                        throw new ArgumentException("Invalid choice. Please choose only from the types in the list.");
                    }
                    else
                    {
                        fuelType = (eFuelTypes)choice;
                    }
                }
                catch (FormatException e)
                {
                    isValid = false;
                    Console.WriteLine(e.Message);
                    Console.WriteLine("Please try again");
                }
                catch (ArgumentException e)
                {
                    isValid = false;
                    Console.WriteLine(e.Message);
                    Console.WriteLine("Please try again");
                }
            }while (!isValid);

            return(fuelType);
        }
Example #7
0
        private void getValidColor(out eVehicleColors o_Color)
        {
            bool   parseSucceeded = false;
            string input;

            o_Color = eVehicleColors.None;

            Console.Clear();
            do
            {
                try
                {
                    Console.WriteLine("Please insert your car color from the following options:");
                    MenusPrinter.PrintColorsMenu();
                    input          = Console.ReadLine();
                    o_Color        = CustomConverter.ConvertStringColorToVehicleColor(input);
                    parseSucceeded = true;
                }
                catch (ArgumentException e)
                {
                    Console.WriteLine(e.Message);
                }
            }while (!parseSucceeded);
        }