예제 #1
0
        static void Main(string[] args)
        {
            Figure figure = new Triangle(5, 7, 4);

            figure.Print();
            Console.WriteLine($"Периметр: {figure.Perimeter()} ");
            Console.WriteLine($"Площадь: {figure.Square()} ");

            Figure figure2 = new Squared(5, 5);

            figure2.Print();
            Console.WriteLine($"Периметр: {figure2.Perimeter()} ");
            Console.WriteLine($"Площадь: {figure2.Square()} ");

            Figure figure3 = new Rhombus(5, 5, 8);

            figure3.Print();
            Console.WriteLine($"Периметр: {figure3.Perimeter()} ");
            Console.WriteLine($"Площадь: {figure3.Square()} ");

            Figure figure4 = new Rectangle(5, 6);

            figure4.Print();
            Console.WriteLine($"Периметр: {figure4.Perimeter()} ");
            Console.WriteLine($"Площадь: {figure4.Square()} ");

            Figure figure5 = new Circle(5, 5, 10);

            figure5.Print();
            Console.WriteLine($"Периметр: {figure5.Perimeter()} ");
            Console.WriteLine($"Площадь: {figure5.Square()} ");
            Console.WriteLine("=============================");


            Compound f = new Compound();

            f.AddFigure(figure2);
            f.AddFigure(figure3);
            f.AddFigure(figure4);
            f.PrintgeneralSquare();


            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args)
        {
            Triangle triangle = new Triangle();
            Random   random = new Random();
            int      k1, k2;             //Катеты
            double   g;                  //Гипотенуза

            for (int i = 0; i < 10; i++) //Заполняем, считаем и выводим в консоль
            {
                k1 = random.Next(1, 100);
                k2 = random.Next(1, 100);
                g  = Math.Sqrt(k1 * k1 + k2 * k2);
                triangle.SetSides(k1, k2, g);
                Console.WriteLine("Sides:  " + triangle.a + ", " + triangle.b + ", " + triangle.c);
                Console.WriteLine("P / 2:  " + triangle.p);
                Console.WriteLine("Square: " + triangle.Square());
                Console.WriteLine();
            }
            Console.ReadKey();
        }