Example #1
0
        public void RunLogic1()
        {
            int arrayLength;

            int[] arr;
            Console.WriteLine("Enter array Length please:");
            try
            {
                TryReadIntParser(out arrayLength);
                arr = new int[arrayLength];
                for (int i = 0; i < arr.Length; i++)
                {
                    Console.WriteLine("Enter Array numbers");
                    try
                    {
                        TryReadIntParser(out arr[i]);
                    }
                    catch (ScubaException e)
                    {
                        Console.WriteLine(String.Format("Hey {0}, You have an exception as ScubaException : {1}", e.StudentNum, e.Message));
                    }
                }
                Console.WriteLine("The result of Logic1 is: " + Logics.Logic1(arr));
            }
            catch (ScubaException e)
            {
                Console.WriteLine(String.Format("Hey {0}, You have an exception as ScubaException : {1}", e.StudentNum, e.Message));
            }
        }
Example #2
0
        public void RunLogic1()
        {
            int arrayLength = 0; //default value for array length

            Console.WriteLine("Please enter array`s size");
            try
            {
                arrayLength = IntParser();
            }
            catch (ScubaException ex)
            {
                Console.WriteLine($"Sorry, student {ex.studentNumber}, You got a ScubaException: {ex.Message}");
            }

            int[] numbersArray = new int[arrayLength];
            Console.WriteLine("Please enter the numbers");
            for (int i = 0; i < arrayLength; i++)
            {
                try
                {
                    numbersArray[i] = IntParser();
                }
                catch (ScubaException ex)
                {
                    Console.WriteLine($"Sorry, student {ex.studentNumber}, You got a ScubaException: {ex.Message}");
                }
            }

            Console.WriteLine("Logic1 function result: " + Logics.Logic1(numbersArray));
        }