Example #1
0
        public static void ExecTask4()
        {
            Console.WriteLine("\n\nTASK 4");
            int s = ValidationInput.GetValueFromConsole("Input a value >0 to calculate a Factorial", "Please input correct value");

            while (s <= 0)
            {
                s = ValidationInput.GetValueFromConsole("Input a value >0 to calculate a Factorial", "Please input correct value");
            }
            Console.WriteLine("Factorial = " + GetFactorial(s));
            Console.ReadKey();
        }
Example #2
0
        public static void ExecTask2()
        {
            Console.WriteLine("\n\nTASK 2");
            int[] arr = Function.GetArrayFromConsole();
            arr = Function.SortArray(arr, false);
            Function.PrintArray(arr);

            int findingValue = ValidationInput.GetValueFromConsole("\nInput a number to find in the array", "Please input correct value");

            if (!SearchValue(findingValue, arr))
            {
                Console.WriteLine("Not Found!");
            }
            else
            {
                Console.WriteLine("FOUND !");
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            int choise = ValidationInput.GetValueFromConsole("Input a number of task 1-4. Input 5 - to start all tasks or another to quit.", "Please input correct value");

            switch (choise)
            {
            case 1:
                Task1.ExecTask1();
                Console.ReadKey();
                break;

            case 2:
                Task2.ExecTask2();
                Console.ReadKey();
                break;

            case 3:
                Task3.ExecTask3();
                Console.ReadKey();
                break;

            case 4:
                Task4.ExecTask4();
                Console.ReadKey();
                break;

            case 5:
                Task1.ExecTask1();
                Task2.ExecTask2();
                Task3.ExecTask3();
                Task4.ExecTask4();
                break;

            default:
                if (choise < 1 || choise > 5)
                {
                    Console.WriteLine("Good Bye...");
                }
                Console.ReadKey();
                break;
            }
        }
Example #4
0
        public static int[] GetArrayFromConsole()
        {
            int nArr = ValidationInput.GetValueFromConsole("Input a number of elemets in array", "Please input correct value");

            while (nArr <= 0)
            {
                nArr = ValidationInput.GetValueFromConsole("Input a number of elemets in array", "Please input correct value");
            }
            int[] mainArray = new int[nArr];
            int   iArr      = 0;

            while (iArr < nArr)
            {
                string element = "Input " + (iArr + 1) + " of " + nArr;
                mainArray[iArr] = ValidationInput.GetValueFromConsole(element, "Please input correct value");
                iArr++;
            }

            return(mainArray);
        }