示例#1
0
 public override void validate()
 {
     if (2 * Sides.Max() >= Sides.Sum())
     {
         throw new ArgumentException("Not a figure");
     }
 }
示例#2
0
        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);
        }
示例#3
0
        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])));
        }