using System.Collections.Generic;
enum TriangleType : byte {Square, Acute, Obtuse}
enum QuadrilateralType : byte {Square, Rectangle}
public int NumSides {get; protected set;}
public abstract double Area();
public override string ToString()
return string.Format("Our figure has {0} side{1}",this.NumSides,this.NumSides > 1 ? "s" : "");
public TwoDShape(int numSides,params int[] num)
this.NumSides = numSides;
this.sides = new int[numSides];
if(num.Length == numSides)
for(int i = 0; i < num.Length;i++)
throw new Exception("Count of parameters on equal count of sides!");
class Triangle : TwoDShape
public TriangleType Type {get; protected set;}
public Triangle(TriangleType style,params int[] num) : base(3,num)
public override double Area()
double halfPerim = (this.sides[0] + this.sides[1] + this.sides[2]) /2;
return Math.Sqrt(halfPerim * (halfPerim - this.sides[0]) * (halfPerim - this.sides[1]) * (halfPerim - this.sides[2]));
public int this[int index]
return this.sides[index];
this.sides[index] = value;
public override string ToString()
for(int i = 0; i < this.sides.Length;i++)
result += string.Format("\nSide {0} : {1}", (char)('A'+i),this.sides[i]);
return string.Format("Triangle\n\nType: {0}\n {1}\n\nArea of triangle: {2}",this.Type,result,this.Area());
abstract class Quadrilateral : TwoDShape
public static void Main()
TwoDShape tri = new Triangle(TriangleType.Square,sides);
Console.WriteLine(tri.ToString());