{ public virtual int x { get; set; }
public virtual int y { get; set; }
public Point(int x, int y) { this.x= x; this.y= y; }
public Point setPoint(Point p)
{ if(p != null) { this.x= p.x; this.y= p.y; }
public override string ToString()
{ return string.Format("({0}:{1})", x, y);
public Shape(Point a, int numb, Point[] p)
this.points= new Point[numb];
for(int i=0; i < numb; i++)
{ this.points[i]= p[i]??(new Point());
{ this.points[i]= new Point();
public override string ToString()
{ for(int i= 0; i < this.points.Length; i++)
else result += "no points";
return base.ToString() + result + "}";
{ public Triangle(Point p, Point[] a): base(p, 3, a) {}
public override string ToString()
{ return "Triangle " + base.ToString();
{ public Rectangle(Point p, Point[] a): base(p, 4, a) {}
public override string ToString()
{ return "Rectangle " + base.ToString();
public static void Main()
Triangle t= new Triangle(new Point(100, 100), new Point[] {new Point(1, 1), new Point(2, 2), new Point(3, 3)});
Rectangle r= new Rectangle(new Point(200, 200), new Point[] {new Point(11, 11), new Point(12, 12), new Point(13, 13), new Point(14, 14)});
Shape[] shapes= new Shape[] {t, r};
for(int i= 0; i < shapes.Length; i++)
Console.WriteLine(shapes[i]);