/// <summary>
        /// Constructor to initialize a rectangle through two or four sides and other paper figure.
        /// </summary>
        /// <param name="sidesCollection">Two or four sides</param>
        public PaperRectangle(IEnumerable <double> sidesCollection, IPaperFigure figure) : base(sidesCollection)
        {
            double area = Sides[0] * Sides[1];

            if (area > figure.GetArea())
            {
                throw new ArgumentException("You cannot create a shape because the original shape is smaller.");
            }

            Color     = figure.Color;
            IsRecolor = true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor to initialize a circle through a radius and other paper figure.
        /// </summary>
        /// <param name="radius">Cicle radius</param>
        /// <param name="figure">Other paper figure</param>
        public PaperCircle(double radius, IPaperFigure figure) : base(radius)
        {
            double area = Math.PI * Math.Pow(Radius, 2);

            if (area > figure.GetArea())
            {
                throw new ArgumentException("You cannot create a shape because the original shape is smaller.");
            }

            Color     = figure.Color;
            IsRecolor = true;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Constructor to initialize a square through one or three sides and other paper figure.
        /// </summary>
        /// <param name="sidesCollection">Three sides</param>
        /// <param name="figure">Other paper figure</param>
        public PaperTriangle(IEnumerable <double> sidesCollection, IPaperFigure figure) : base(sidesCollection)
        {
            double halfPerimetr = Sides.Sum() / 2;
            double area         = Math.Sqrt(halfPerimetr * (halfPerimetr - Sides[0]) * (halfPerimetr - Sides[1]) * (halfPerimetr - Sides[2]));

            if (area > figure.GetArea())
            {
                throw new ArgumentException("You cannot create a shape because the original shape is smaller.");
            }

            Color     = figure.Color;
            IsRecolor = true;
        }