private string[] AskInputParams()
        {
            string[] result = new string[InputDTO.CountParams];

            Console.WriteLine("Enter a number");
            result[0] = Console.ReadLine();

            result[1] = ((InputDTO.Algorithms)
                         BaseConsoleUI.AskMenuItem("Choose language"
                                                   , typeof(InputDTO.Algorithms))).ToString();

            return(result);
        }
Exemple #2
0
        public static string[] AskInputRangeParams()
        {
            List <string> result = new List <string>();

            do
            {
                result.AddRange(AskInputParams());
                if (!BaseConsoleUI.AskСonfirmation("Do you want to add a new triangel?"
                                                   , new string[] { "YES", "Y" }))
                {
                    break;
                }
            } while (true);

            return(result.ToArray());
        }
        public void ExecuteProgramm(string[] args)
        {
            bool isNewTry = false;

            do
            {
                if (isNewTry)
                {
                    args     = AskInputParams();
                    isNewTry = false;
                }

                if (!IsValid(args))
                {
                    Console.WriteLine("Your data is not valid");
                    if (!BaseConsoleUI.AskСonfirmation("Do you want to retype them?",
                                                       new string[] { "YES", "Y" }))
                    {
                        break;
                    }

                    args = AskInputParams();

                    continue;
                }

                InputDTO inputDTO = Parser.Parse(args);

                NumberToTextConverter converter;

                switch (inputDTO.Algorithm)
                {
                case InputDTO.Algorithms.English:
                    converter = new EnglishNumberToTextConverter();
                    break;

                default:
                    converter = new EnglishNumberToTextConverter();
                    break;
                }

                Number number = new Number(inputDTO.Number, converter);

                if (number.CanConvertToText())
                {
                    Console.WriteLine(number.ConvertToText());
                }
                else
                {
                    Console.WriteLine(
                        "This converter can't convert the number. " +
                        "The number is too big.");
                }

                if (BaseConsoleUI.AskСonfirmation("Do you want to continue?",
                                                  new string[] { "YES", "Y" }))
                {
                    isNewTry = true;
                }
                else
                {
                    break;
                }
            } while (true);
        }