コード例 #1
0
ファイル: ApplicationManager.cs プロジェクト: avithalker/rep
        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));
            }
        }
コード例 #2
0
ファイル: ApplicationManager.cs プロジェクト: avithalker/rep
        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);
        }
コード例 #3
0
ファイル: ApplicationManager.cs プロジェクト: avithalker/rep
        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);
        }
コード例 #4
0
ファイル: ApplicationManager.cs プロジェクト: avithalker/rep
        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);
        }
コード例 #5
0
ファイル: ApplicationManager.cs プロジェクト: avithalker/rep
        public void Run()
        {
            eMainMenuOptions mainMenuChoice = eMainMenuOptions.InvalidChoice;

            do
            {
                MenusPrinter.PrintMainMenu();
                mainMenuChoice = getUserChoice();
                doActionUserByMainMenuChoice(mainMenuChoice);
            }while (mainMenuChoice != eMainMenuOptions.ExitProgram);
        }
コード例 #6
0
ファイル: ApplicationManager.cs プロジェクト: avithalker/rep
        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);
        }
コード例 #7
0
ファイル: ApplicationManager.cs プロジェクト: avithalker/rep
        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);
        }