using System; public class Polygon { private Point[] corners; public Polygon(params Point[] corners){ this.corners = new Point[corners.Length]; // Copy corners into instance variable: for(int i = 0; i < corners.Length; i++) this.corners[i] = new Point(corners[i]); } private Line[] Edges(){ Line[] res = new Line[corners.Length]; int Lgt = corners.Length; for (int i = 0; i < Lgt - 1; i++) res[i] = new Line(corners[i], corners[i+1]); res[Lgt-1] = new Line(corners[Lgt-1], corners[0]); return res; } public virtual double Circumference(){ double res = 0; foreach(Line ln in this.Edges()) res += ln.Length(); return res; } public virtual int Rank{ get { return corners.Length;} } } internal class Line{ private Point p1, p2; public Line(Point p1, Point p2){ this.p1 = new Point(p1); this.p2 = new Point(p2); } public double Length(){ return Math.Sqrt( Square(p1.X - p2.X) + Square(p1.Y - p2.Y)); } private static double Square(double a){ return a * a; } }