Exemplo n.º 1
0
        /// <summary>
        /// Reading from file for TASK1.
        /// </summary>
        public static void ReadFileTASK1()
        {
            string[] lines = File.ReadAllLines(@"fileTASK1.txt");

            var line1 = lines[0].Split(',');

            P1.Point a = new P1.Point(int.Parse(line1[0]), int.Parse(line1[1]));

            var line2 = lines[1].Split(',');

            P1.Point b = new P1.Point(int.Parse(line2[0]), int.Parse(line2[1]));

            P1.Rectangle rect = new P1.Rectangle(a, b);
            Console.WriteLine("------TASK1------");
            Console.WriteLine(rect);
            Console.WriteLine($"Perimetr = {rect.Perimetr()}");
            Console.WriteLine($"Square = {rect.Square()}\n");

            var line3 = lines[2].Split(',');

            P1.Point a1 = new P1.Point(int.Parse(line3[0]), int.Parse(line3[1]));

            var line4 = lines[3].Split(',');

            P1.Point b1 = new P1.Point(int.Parse(line4[0]), int.Parse(line4[1]));
            P1.RectangleProperties rect_prop = new P1.RectangleProperties(a1, b1);

            Console.WriteLine("------TASK2------");
            Console.WriteLine(rect_prop);
            Console.WriteLine($"Perimetr = {rect_prop.Perimetr}");
            Console.WriteLine($"Square = {rect_prop.Square}\n");

            Console.WriteLine("------TASK3------");
            Console.WriteLine("Circle");
            var    line5  = lines[4];
            double radius = double.Parse(line5);

            P1.Circle circle = new P1.Circle(radius);
            Console.Write($"Radius = {radius}");
            Console.WriteLine($"Square = {circle.Square()}");
            Console.WriteLine($"Length = {circle.Length()}");

            Console.WriteLine("------TASK4------");
            var line6 = lines[5].Split(',');

            P1.Point a2    = new P1.Point(int.Parse(line6[0]), int.Parse(line6[1]));
            var      line7 = lines[6].Split(',');

            P1.Point b2 = new P1.Point(int.Parse(line7[0]), int.Parse(line7[1]));

            Console.WriteLine("Static Rectangle");
            Console.WriteLine($"Perimetr = {P1.StaticClasses.Rectangle.Perimetr(a2, b2)}");
            Console.WriteLine($"Square = {P1.StaticClasses.Rectangle.Square(a2, b2)}\n");

            var    line8   = lines[7];
            double radius1 = double.Parse(line8);

            Console.WriteLine("Static Circle");
            Console.WriteLine($"Square = {P1.StaticClasses.Circle.Square(radius1)}");
            Console.WriteLine($"Length = {P1.StaticClasses.Circle.Length(radius1)}");

            Console.WriteLine("------TASK5------");
            var line9 = lines[8].Split(',');

            P1.ComplexNumber complex1 = new P1.ComplexNumber(double.Parse(line9[0]), double.Parse(line9[1]));
            Console.Write($"Complex1 = {complex1}");

            var line10 = lines[9].Split(',');

            P1.ComplexNumber complex2 = new P1.ComplexNumber(double.Parse(line10[0]), double.Parse(line10[1]));
            Console.Write($"Complex2 = {complex2}");

            Console.WriteLine($"Multiplication = {complex1 * complex2}");
            Console.WriteLine($"Division = {complex1 * complex2}");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reading from console for TASK1.
        /// </summary>
        public static void ConsoleTASK1()
        {
            Console.WriteLine("------TASK1------");
            Console.WriteLine("Rectangle");
            Console.WriteLine("Left Top coordinates");
            Console.Write("Enter x1: ");
            int x1 = int.Parse(Console.ReadLine());

            Console.Write("Enter y1: ");
            int y1 = int.Parse(Console.ReadLine());

            Console.WriteLine("Right Bottom coordinates");
            Console.Write("Enter x2: ");
            int x2 = int.Parse(Console.ReadLine());

            Console.Write("Enter y2: ");
            int y2 = int.Parse(Console.ReadLine());

            P1.Point     a    = new P1.Point(x1, y1);
            P1.Point     b    = new P1.Point(x2, y2);
            P1.Rectangle rect = new P1.Rectangle(a, b);
            Console.WriteLine($"Perimetr = {rect.Perimetr()}");
            Console.WriteLine($"Square = {rect.Square()}\n");

            Console.WriteLine("------TASK2------");
            Console.WriteLine("RectangleProperties");
            Console.WriteLine("Left Top coordinates");
            Console.Write("Enter x1: ");
            int x11 = int.Parse(Console.ReadLine());

            Console.Write("Enter y1: ");
            int y11 = int.Parse(Console.ReadLine());

            Console.WriteLine("Right Bottom coordinates");
            Console.Write("Enter x2: ");
            int x21 = int.Parse(Console.ReadLine());

            Console.Write("Enter y2: ");
            int y21 = int.Parse(Console.ReadLine());

            P1.Point a1 = new P1.Point(x11, y11);
            P1.Point b1 = new P1.Point(x21, y21);
            P1.RectangleProperties rect_prop = new P1.RectangleProperties(a1, b1);
            Console.WriteLine(rect_prop);
            Console.WriteLine($"Perimetr = {rect_prop.Perimetr}");
            Console.WriteLine($"Square = {rect_prop.Square}\n");

            Console.WriteLine("------TASK3------");
            Console.WriteLine("Circle");
            Console.Write("Enter radius: ");
            double radius = double.Parse(Console.ReadLine());

            P1.Circle circle = new P1.Circle(radius);
            Console.WriteLine($"Square = {circle.Square()}");
            Console.WriteLine($"Length = {circle.Length()}");

            Console.WriteLine("------TASK4------");
            Console.WriteLine("Static Rectangle");
            Console.WriteLine($"Perimetr = {P1.StaticClasses.Rectangle.Perimetr(a, b)}");
            Console.WriteLine($"Square = {P1.StaticClasses.Rectangle.Square(a, b)}\n");

            Console.WriteLine("Static Circle");
            Console.WriteLine($"Square = {P1.StaticClasses.Circle.Square(radius)}");
            Console.WriteLine($"Length = {P1.StaticClasses.Circle.Length(radius)}");

            Console.WriteLine("------TASK5------");
            Console.WriteLine("Complex Number");
            Console.Write("Enter real1: ");
            double real1 = double.Parse(Console.ReadLine());

            Console.Write("Enter imaginary1: ");
            double imaginary1 = double.Parse(Console.ReadLine());

            Console.Write("Enter real2: ");
            double real2 = double.Parse(Console.ReadLine());

            Console.Write("Enter imaginary2: ");
            double imaginary2 = double.Parse(Console.ReadLine());

            P1.ComplexNumber complex1 = new P1.ComplexNumber(real1, imaginary1);
            P1.ComplexNumber complex2 = new P1.ComplexNumber(real2, imaginary2);

            Console.WriteLine($"Multiplication = {complex1 * complex2}");
            Console.WriteLine($"Division = {complex1 * complex2}");
            Console.ReadKey();
        }