예제 #1
0
        public void Run()
        {
            UI.Write("Enter n:");
            int.TryParse(UI.Read(), out var n);
            UI.Write("Enter m:");
            int.TryParse(UI.Read(), out var m);
            var random = new Random();

            var numbers = new int[n, m];

            for (int i = 0; i < numbers.GetLength(0); i++)
            {
                for (int j = 0; j < numbers.GetLength(1); j++)
                {
                    numbers[i, j] = random.Next(0, 1000);
                }
            }

            int sum         = AsyncSum.Sum(numbers);
            int compererSum = numbers.Cast <int>().Sum();

            if (sum == compererSum)
            {
                UI.Write("Its correct");
            }
            else
            {
                UI.Write("Its not correct, right answer is:" + compererSum.ToString());
            }
            UI.Write(sum.ToString());
        }
예제 #2
0
        public void Run()
        {
            var fileReader = new DirectoryReader();

            UI.Write("Enter path:");
            string path = UI.Read();
            var    contentFormDirectory = new List <string>();

            try
            {
                contentFormDirectory = fileReader.GetContentFromDirectory(path);
            }
            catch (ArgumentException e)
            {
                _logger.Error(e);
            }

            foreach (var item in contentFormDirectory)
            {
                UI.Write(item);
            }

            var searchingTxtInDirectory = new SearchingTxtInDirectory();

            UI.Write("Enter path:");
            path = UI.Read();
            UI.Write("Enter name of .txt:");
            string        name       = UI.Read();
            List <string> foundedTxt = searchingTxtInDirectory.SearchTxtInDirectory(path, name);

            foreach (var item in foundedTxt)
            {
                UI.Write(item);
            }
        }
예제 #3
0
        public void Run()
        {
            try
            {
                ExceptionCaller.DoStackOverflowException();
                ExceptionCaller.DoIndexOutOfRangeException();
            }
            catch (StackOverflowException e)
            {
                UI.Write(e.Message);
            }
            catch (IndexOutOfRangeException e)
            {
                UI.Write(e.Message);
            }

            try
            {
                ExceptionCaller.DoSomeMath(-8, 10);
            }
            catch (ArgumentException e)
                when(e.ParamName == "a")
                {
                    UI.Write(e.Message);
                }
            catch (ArgumentException e)
                when(e.ParamName == "b")
                {
                    UI.Write(e.Message);
                }
        }
예제 #4
0
        public void Run()
        {
            UI.Write("Enter Name:");
            string name = UI.Read();

            UI.Write("Enter Surname:");
            string surname = UI.Read();

            int age;

            UI.Write("Enter Age:");
            int.TryParse(UI.Read(), out age);

            var person = new Person()
            {
                Name = name, Surname = surname, Age = age
            };

            UI.Write("Enter the comparative age:");
            int comparativeAge;

            int.TryParse(UI.Read(), out comparativeAge);
            UI.Write($"{person.CompareAge(comparativeAge)}");

            UI.Write("Enter X coordinate:");
            double x;

            double.TryParse(UI.Read(), out x);

            UI.Write("Enter Y coordinate:");
            double y;

            double.TryParse(UI.Read(), out y);

            UI.Write("Enter Height:");
            double heigth;

            double.TryParse(UI.Read(), out heigth);

            UI.Write("Enter Width:");
            double width;

            double.TryParse(UI.Read(), out width);

            var rectangle = new Rectangle()
            {
                X      = x,
                Y      = y,
                Height = heigth,
                Width  = width
            };

            UI.Write($"Perimeter of rectangle: {rectangle.GetPerimeter(rectangle.Width, rectangle.Height)}");
        }
예제 #5
0
        public void Run()
        {
            UI.Write("Write number");
            int number;

            int.TryParse(UI.Read(), out number);
            UI.Write($"{(Months)number}");

            Colors colors = Colors.Blue;

            colors.GetSortedColors();

            UI.Write($"The values of LongRange enum:");
            foreach (var item in Enum.GetValues(typeof(LongRange)))
            {
                UI.Write($"{item}");
            }
        }
        public void Run()
        {
            var           assemblyInfo       = new AssemblyInfo();
            List <string> assemblyStringInfo = assemblyInfo.GetAssemblyInfo();

            foreach (var item in assemblyStringInfo)
            {
                UI.Write(item);
            }
        }