/// <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"); } }
/// <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; }
/// <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); }
public double GetArea(IFigure figure) { if (figure != null) { return(figure.GetArea()); } else { throw new NullReferenceException(); } }
public static double GetArea(IFigure figure) { return(figure.GetArea()); }
/// <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)); }
public void Test(IFigure figure, double expectedArea, double expectedPerimeter) { Assert.That(figure.GetArea(), Is.EqualTo(expectedArea)); Assert.That(figure.GetPerimeter(), Is.EqualTo(expectedPerimeter)); }
/// <summary> /// Gets area of the figure /// </summary> /// <returns>Area of the figure</returns> public double GetArea() { return(_figure.GetArea()); }
//не знаю, правильно ли я понял получение площади без знания фигуры private static double GetArea(IFigure figure) { return(figure.GetArea()); }
public static float GetArea(IFigure figure) { return(figure.GetArea()); }
private double GetArea(IFigure figure) => figure.GetArea();