/// <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(IFigure figure, double a, double b, double c)
 {
     if (!IsExist(a, b, c))
     {
         throw new InvalidParametersException();
     }
     sides = new double[] { a, b, c };
     if (figure.GetSquare() < GetSquare())
     {
         throw new CutException();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the Rectangle class, cutting from another figure
 /// </summary>
 /// <param name="figure"> Figure for cutting</param>
 /// <param name="a"> Width of a rectangle</param>
 /// <param name="b"> Height of a rectangle</param>
 public Rectangle(IFigure figure, double a, double b)
 {
     if (a <= 0 || b <= 0)
     {
         throw new InvalidParametersException();
     }
     sides = new double[] { a, b };
     if (figure.GetSquare() < GetSquare())
     {
         throw new CutException();
     }
 }
Ejemplo n.º 3
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(IFigure figure, double radius)
 {
     if (radius <= 0)
     {
         throw new InvalidParametersException();
     }
     this.radius = radius;
     if (figure.GetSquare() < GetSquare())
     {
         throw new CutException();
     }
 }
Ejemplo n.º 4
0
    public static void Main(string[] args)
    {
        try
        {
            IFigure firstFigure  = Figure.Parse(Console.ReadLine());
            IFigure secondFigure = Figure.Parse(Console.ReadLine());

            Console.WriteLine($"{firstFigure.GetPerimeter():F3} and {secondFigure.GetPerimeter():F3}");
            Console.WriteLine($"{firstFigure.GetSquare():F3} and {secondFigure.GetSquare():F3}");

            Console.WriteLine($"{firstFigure.CompareByPerimeter(secondFigure) > 0}");
            Console.WriteLine($"{firstFigure.CompareBySquare(secondFigure) > 0}");
        }
        catch (ArgumentException argumentException)
        {
            Console.WriteLine(argumentException.Message);
        }
    }
Ejemplo n.º 5
0
 /// <summary>
 /// Возвращает площадь уже созданной фигуры
 /// </summary>
 /// <param name="figure">Объект класса наследника IFigure</param>
 /// <returns>Площадь фигуры</returns>
 public static double CalculateSquare(IFigure figure)
 {
     return(figure.GetSquare());
 }
        public void CheckArea(double expectArea, params double[] values)
        {
            IFigure figure = factory.CreateFigure(Material.Film, values);

            Assert.AreEqual(expectArea, figure.GetSquare(), 0.00001f);
        }
Ejemplo n.º 7
0
 static void Foo(IFigure figure)
 {
     Console.WriteLine("Площадь = " + figure.GetSquare().ToString());
 }
Ejemplo n.º 8
0
 public double GetSquare() => _figure.GetSquare();