static void Main(string[] args)
        {
            TwoDShape[] shapes = new TwoDShape[5];
            shapes[0] = new Triangle("прямоугольный", 8.0, 12.0);
            shapes[1] = new Rectangle(10);
            shapes[2] = new Rectangle(10, 4);
            shapes[3] = new Triangle(7.0);
            shapes[4] = new TwoDShape(10, 20, "общая форма");
            for (int i = 0; i < shapes.Length; i++)
            {
                Console.WriteLine("Объект — " + shapes[i].name);
                Console.WriteLine("Площадь равна " + shapes[i].Area());
                Console.WriteLine();
            }

            Console.ReadKey();
        }
Пример #2
0
 // Сконструировать копию объекта TwoDShape.
 public TwoDShape(TwoDShape ob)
 {
     Width  = ob.Width;
     Height = ob.Height;
 }
 // Сконструировать копию объекта TwoDShape.
 public TwoDShape(TwoDShape ob)
 {
     Width  = ob.Width;
     Height = ob.Height;
     name   = ob.name;
 }