class Rectangle : TwoDShape {
// Конструктор для класса Rectangle,
public Rectangle(double w, double h)
: base(w, h, "прямоугольник"){ }
// Сконструировать квадрат,
public Rectangle(double x) : base (x, "прямоугольник") { }
// Сконструировать копию объекта типа Rectangle,
public Rectangle(Rectangle ob) : base(ob) { }
// Возвратить логическое значение true, если
// прямоугольник окажется квадратом,
public bool IsSquare() {
if(Width == Height) return true;
return false;
}
// Переопределить метод Area() для класса Rectangle,
public override double Area() {
return Width * Height;
}
}
class AbsShape {
static void Main() {
TwoDShape[] shapes = new TwoDShape[4];
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);
for(int i=0; i < shapes.Length; i++) {
Console.WriteLine("Объект — " + shapes[i].name);
Console.WriteLine("Площадь равна " + shapes[i].Area());
Console.WriteLine() ;