Ejemplo n.º 1
0
        public string GetTree()
        {
            while (true)
            {
                string A      = TextForWork.Get("A parameter");
                string B      = TextForWork.Get("B parameter");
                int    digitA = Character.GetDigit(A);
                int    digitB = Character.GetDigit(B);

                if (!Character.CheckIfDigit(A) || !Character.CheckIfDigit(B))
                {
                    Console.WriteLine("You've entered character insted of digit");
                }
                else if (digitA >= digitB)
                {
                    Console.WriteLine("Sorry, but A has to be less than B");
                }
                else
                {
                    string result = PrintTree(digitA, digitB);

                    TextForWork.PrintToTheFile(4, result);
                    return(result);
                }
                Console.WriteLine("Please try again");
            }
        }
Ejemplo n.º 2
0
        public string GetCount()
        {
            Console.WriteLine("Enter your symbols: ");
            Console.WriteLine("To quit enter '.'");
            int spaceCount = 0;

            while (true)
            {
                var charToCheck = Console.ReadKey().KeyChar;

                if (charToCheck == '.')
                {
                    break;
                }
                if (charToCheck == ' ')
                {
                    spaceCount++;
                }
            }
            string result = $"The amount of spaces is: {spaceCount}";

            TextForWork.PrintToTheFile(1, result);

            return(result);
        }
        public string ConvertText()
        {
            string input = TextForWork.Get("text");

            string result = GetUpLowCase(input);

            TextForWork.PrintToTheFile(3, result);

            return($"Your result text is: {result}");
        }
Ejemplo n.º 4
0
        public string CheckIfLucky()
        {
            string ticket = CheckIfCorrect();

            if (CheckIfEqual(ticket))
            {
                string result = "Congratulations! You have a lucky ticket!";
                TextForWork.PrintToTheFile(2, result);
                return(result);
            }
            else
            {
                string result = "Sorry. Your ticket isn't lucky";
                TextForWork.PrintToTheFile(2, result);
                return(result);
            }
        }
Ejemplo n.º 5
0
        public string GetNumber()
        {
            while (true)
            {
                string unconvertedNumber = TextForWork.Get("number");

                if (!Character.CheckIfDigit(unconvertedNumber))
                {
                    Console.WriteLine("Sorry, number can hold only digits and can't be negative");
                }
                else
                {
                    int numberReversed = Character.GetMirror(unconvertedNumber);

                    string result = numberReversed.ToString();

                    TextForWork.PrintToTheFile(5, result);
                    return(result);
                }
                Console.WriteLine("Please try again");
            }
        }
Ejemplo n.º 6
0
        public string CheckIfCorrect()
        {
            string ticketNumber;

            while (true)
            {
                ticketNumber = TextForWork.Get("ticket number");

                if (ticketNumber.Length != digitСount)
                {
                    Console.WriteLine("You've entered incorrect amount of digits");
                }
                else if (!Character.CheckIfDigit(ticketNumber))
                {
                    Console.WriteLine("You've entered character insted of digit");
                }
                else
                {
                    break;
                }
                Console.WriteLine("Please try again");
            }
            return(ticketNumber);
        }