public override void validate() { if (2 * Sides.Max() >= Sides.Sum()) { throw new ArgumentException("Not a figure"); } }
private bool CalcIsPrimitive() { var nonZeroSides = Sides.Where(s => s != 0).ToArray(); for (int f = 2; f <= (int)Math.Ceiling((double)Sides.Max()); f++) { if (nonZeroSides.All(s => Numerics.IsIntegral((double)s / f))) { return(false); } } return(true); }
public override double area() { validate(); if (2 * Sides.Max() >= Sides.Sum()) { throw new ArgumentException("Not a figure"); } if (Math.Pow(Sides.Max(), 2) * 2 == Math.Pow(Sides[0], 2) + Math.Pow(Sides[1], 2) + Math.Pow(Sides[2], 2)) { return(Sides[0] * Sides[1] * Sides[2] / Sides.Max() / 2); } double hper = Sides.Sum() / 2; return(Math.Sqrt(hper * (hper - Sides[0]) * (hper - Sides[1]) * (hper - Sides[2]))); }