Esempio n. 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());
        }
Esempio n. 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);
            }
        }
Esempio n. 3
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)}");
        }
Esempio n. 4
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}");
            }
        }