/// <summary>
 /// Instance constructor for creating a circle figure through the radius and another figure
 /// </summary>
 /// <param name="radius">Circle radius</param>
 /// <param name="cutOutFigure">Cut out the figure</param>
 protected Circle(double radius, IFigure cutOutFigure) : this(radius)
 {
     if (GetArea() > cutOutFigure.GetArea())
     {
         throw new OutOfAreaException("You can't cut a figure because the original shape is smaller", this, cutOutFigure);
     }
 }
 /// <summary>
 /// Instance constructor for creating a triangle figure figure through the sides and another figure
 /// </summary>
 /// <param name="sides">Triangle sides</param>
 /// <param name="cutOutFigure">Cut out the figure</param>
 protected Triangle(IEnumerable <double> sides, IFigure cutOutFigure) : this(sides)
 {
     if (GetArea() > cutOutFigure.GetArea())
     {
         throw new OutOfAreaException("You can't cut a figure because the original shape is smaller", this, cutOutFigure);
     }
 }
 /// <summary>
 /// Constructor to create an object from a given.
 /// </summary>
 /// <param name="filmTriangle">filmTriangle</param>
 public FilmTriangle(IFigure polygonFigure, List <double> sides) : base(sides)
 {
     if (GetArea() > polygonFigure.GetArea())
     {
         throw new ArgumentException("Can't create a new shape with a larger radius", "Radius");
     }
 }
Exemple #4
0
        /// <summary>
        /// Constructor to create an object from a given.
        /// </summary>
        /// <param name="paperRectangle">paperRectangle</param>
        public PaperRectangle(IFigure polygonFigure, List <double> sides, Color color) : base(sides)
        {
            if (GetArea() > polygonFigure.GetArea())
            {
                throw new ArgumentException("Can't create a new shape with a larger area", "Area");
            }

            Color = color;
        }
Exemple #5
0
        /// <summary>
        /// Constructor to create an object from a given.
        /// </summary>
        /// <param name="paperCirlce">paperCirlce</param>
        public PaperCircle(IFigure polygonFigure, List <double> sides, Color color) : base(sides[0])
        {
            if (GetArea() > polygonFigure.GetArea())
            {
                throw new ArgumentException("Can't create a new shape with a larger radius", "Radius");
            }

            Color = color;
        }
        public int CompareTo(IFigure triangle)
        {
            int comparison = GetArea().CompareTo(triangle.GetArea());

            if (comparison == 0)
            {
                comparison = Name.CompareTo(triangle.Name);
            }

            return(comparison);
        }
Exemple #7
0
 public double GetArea(IFigure figure)
 {
     if (figure != null)
     {
         return(figure.GetArea());
     }
     else
     {
         throw new NullReferenceException();
     }
 }
Exemple #8
0
 public static double GetArea(IFigure figure)
 {
     return(figure.GetArea());
 }
Exemple #9
0
 /// <summary>
 /// Возвращает площадь для любой фигуры.
 /// </summary>
 /// <param name="figure"><see cref="IFigure"/>.</param>
 /// <param name="accuracy">Точность вычисления площади (количество знаков после запятой).</param>
 public static double GetArea(
     IFigure figure,
     int accuracy = 2)
 {
     return(figure.GetArea(accuracy));
 }
Exemple #10
0
 public void Test(IFigure figure, double expectedArea, double expectedPerimeter)
 {
     Assert.That(figure.GetArea(), Is.EqualTo(expectedArea));
     Assert.That(figure.GetPerimeter(), Is.EqualTo(expectedPerimeter));
 }
Exemple #11
0
 /// <summary>
 /// Gets area of the figure
 /// </summary>
 /// <returns>Area of the figure</returns>
 public double GetArea()
 {
     return(_figure.GetArea());
 }
Exemple #12
0
 //не знаю, правильно ли я понял получение площади без знания фигуры
 private static double GetArea(IFigure figure)
 {
     return(figure.GetArea());
 }
Exemple #13
0
 public static float GetArea(IFigure figure)
 {
     return(figure.GetArea());
 }
Exemple #14
0
 private double GetArea(IFigure figure) => figure.GetArea();