Example #1
0
        public static int ReadInt(string prompt, List <Option> options)
        {
            Output.DisplayPrompt(prompt);

            string input = Console.ReadLine();

            if (input == "")
            {
                for (var i = 0; i < options.Count; i++)
                {
                    if (options[i].Name == go_back_menu)
                    {
                        return(i + 1);
                    }
                }
            }

            int value;

            while (!int.TryParse(input, out value) || ((value < 1) || (value > options.Count)))
            {
                Output.DisplayPrompt("Please enter an integer from 1 to " + options.Count);
                input = Console.ReadLine();
            }

            return(value);
        }
Example #2
0
        public static string ReadString(string prompt)
        {
            Output.DisplayPrompt(prompt);
            var input = ReadLine();

            return(input);
        }
Example #3
0
        public static int ReadInt(int min, int max)
        {
            int value = ReadInt();

            while (value < min || value > max)
            {
                Output.DisplayPrompt("Please enter an integer between {0} and {1} (inclusive)", min, max);
                value = ReadInt();
            }
            return(value);
        }
Example #4
0
        public static DateTime ReadDate(string prompt, DateTime min, DateTime max)
        {
            DateTime value = ReadDate(prompt);

            while (value < min || value > max)
            {
                Output.DisplayPrompt("Please enter a date between {0} and {1} (inclusive)", min, max);
                value = ReadDate(prompt);
            }
            return(value);
        }
Example #5
0
        public static double ReadDouble(string prompt, float min, float max)
        {
            double value = ReadDouble(prompt);

            while (value < min || value > max)
            {
                Output.DisplayPrompt("Please enter a numeric value between {0} and {1} (inclusive)", min, max);
                value = ReadDouble(prompt);
            }
            return(value);
        }
Example #6
0
        public static int ReadInt()
        {
            string input = ReadLine();
            int    value;

            while (!int.TryParse(input, out value))
            {
                Output.DisplayPrompt("Please enter an integer");
                input = ReadLine();
            }
            return(value);
        }
Example #7
0
        public static int ReadInt(int min, int max)
        {
            int value = ReadInt();

            while (value < min || value > max)
            {
                Output.DisplayPrompt("Por favor digite um inteiro entre {0} e {1} (inclusive)", min, max);
                value = ReadInt();
            }

            return(value);
        }
Example #8
0
        public static double ReadDouble(string prompt)
        {
            Output.DisplayPrompt(prompt);
            string input = ReadLine();
            double value;

            while (!double.TryParse(input, out value))
            {
                Output.DisplayPrompt("Please enter a numeric value");
                input = ReadLine();
            }
            return(value);
        }
Example #9
0
        public static DateTime ReadDate(string prompt)
        {
            Output.DisplayPrompt(prompt);
            string   input = ReadLine();
            DateTime value;

            while (!DateTime.TryParse(input, out value))
            {
                Output.DisplayPrompt("Please enter a valid date-time");
                input = ReadLine();
            }
            return(value);
        }
Example #10
0
        public static int ReadInt()
        {
            string input = Console.ReadLine();
            int    value;

            while (!int.TryParse(input, out value))
            {
                Output.DisplayPrompt("Por favor insira um inteiro");
                input = Console.ReadLine();
            }

            return(value);
        }
Example #11
0
 public static string ReadString(string prompt)
 {
     Output.DisplayPrompt(prompt);
     return(Console.ReadLine());
 }
Example #12
0
 public static int ReadInt(string prompt, int min, int max)
 {
     Output.DisplayPrompt(prompt);
     return(ReadInt(min, max));
 }
Example #13
0
 public static ConsoleKeyInfo ReadKey(string prompt)
 {
     Output.DisplayPrompt(prompt);
     return(Console.ReadKey());
 }