コード例 #1
0
        private object getBoolInfo(string i_toAskUser)
        {
            bool   goodInput = false;
            int    choise    = 0;
            string userChoise;

            i_toAskUser += String.Format("\n Choose :\n 1. YES \n 2. No");
            Console.WriteLine(i_toAskUser);

            while (!goodInput)
            {
                userChoise = getOnlyDigitsString();
                choise     = int.Parse(userChoise);

                try
                {
                    Validation.IsInRange(choise, 1, 2);
                    goodInput = true;
                }
                catch (Exception ex)
                {
                    AnnounceError(ex);
                    Console.WriteLine(@"Please Enter Again:
");
                }
            }

            return(choise);
        }
コード例 #2
0
        internal int GetUserActionChoise()
        {
            bool   goodInput  = false;
            string choise     = Console.ReadLine();
            int    userChoise = 0;

            while (!goodInput)
            {
                try
                {
                    userChoise = int.Parse(choise);
                    Validation.IsInRange(userChoise, 1, 8);
                    goodInput = true;
                }
                catch (Exception ex)
                {
                    AnnounceError(ex);
                    choise = Console.ReadLine();
                }
            }

            Console.Clear();
            return(userChoise);
        }
コード例 #3
0
        private object getEnumInfo(string i_toAskUser, string[] i_EnumString)
        {
            int    numOfOption = 1, choise = 0;
            bool   goodInput = false;
            string userChoise;

            i_toAskUser += string.Format("\n The Options Are: ");

            foreach (string enumName in i_EnumString)
            {
                string fixedName = GarageData.FixNameToPrint(enumName);
                i_toAskUser += string.Format("\n {0}. {1} ", numOfOption, fixedName);
                numOfOption++;
            }

            Console.WriteLine(i_toAskUser);

            while (!goodInput)
            {
                try
                {
                    userChoise = getOnlyDigitsString();
                    choise     = int.Parse(userChoise);
                    Validation.IsInRange(choise, 0, numOfOption - 1);
                    goodInput = true;
                }
                catch (Exception ex)
                {
                    AnnounceError(ex);
                    Console.WriteLine(@"Please Enter Again:
");
                }
            }

            return(choise);
        }