/// <summary>
 /// Initializes a new instance of the Triangle class, cutting from another figure
 /// </summary>
 /// <param name="figure"> Figure for cutting</param>
 /// <param name="a"> First side of a triangle</param>
 /// <param name="b"> Second side of a triangle</param>
 /// <param name="c"> Third side of a triangle</param>
 public Triangle(Figure figure, float a, float b, float c)
 {
     if (figure == null)
     {
         throw new ArgumentNullException(nameof(figure));
     }
     if (a <= 0 || b <= 0 || c <= 0)
     {
         throw new Exception("Invalid figure's parameters");
     }
     if ((a + b) > c && (a + c) > b && (b + c) > a)
     {
         SideA = a;
         SideB = b;
         SideC = c;
     }
     else
     {
         throw new Exception("Such a triangle cannot exist.");
     }
     if (figure.GetArea() < GetArea())
     {
         throw new Exception("The figure cannot be created.");
     }
 }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the Circle class, cutting from another figure
        /// </summary>
        /// <param name="figure"> Figure for cutting</param>
        /// <param name="radius"> Circle radius</param>
        public Circle(Figure figure, float radius)
        {
            if (figure == null)
            {
                throw new ArgumentNullException(nameof(figure));
            }
            if (radius <= 0)
            {
                throw new Exception("Invalid figure's parameters");
            }

            Radius = radius;

            if (figure.GetArea() < GetArea())
            {
                throw new Exception("The figure cannot be created.");
            }
        }
        /// <summary>
        /// Initializes a new instance of the Rectangle class, cutting from another figure
        /// </summary>
        /// <param name="figure"> Figure for cutting</param>
        /// <param name="width"> Width of a rectangle</param>
        /// <param name="height"> Height of a rectangle</param>
        public Rectangle(Figure figure, float width, float height)
        {
            if (figure == null)
            {
                throw new ArgumentNullException(nameof(figure));
            }
            if (width <= 0 || height <= 0)
            {
                throw new Exception("Invalid figure's parameters");
            }

            Width  = width;
            Height = height;

            if (figure.GetArea() < GetArea())
            {
                throw new Exception("The figure cannot be created.");
            }
        }