I got next task: Add constructor that receives an arbitrary amount of objects of type Rectangle or an array of objects of type Rectangle.
To solve it, I made two constructors. But if I understood correctly by the conditions of the problem, it should be one constructor. How to combine them? Or is it impossible?
public ArrayRectangles(IEnumerable<Rectangle> rectangles)
{
rectangle_array = rectangles.ToArray();
}
public ArrayRectangles(Rectangle[] rectangle_array)
{
this.rectangle_array = new Rectangle[rectangle_array.Length];
for (int i = 0; i < rectangle_array.Length; i++)
{
if (rectangle_array[i] != null)
{
this.rectangle_array[i] = new Rectangle(rectangle_array[i].GetSideA(), rectangle_array[i].GetSideB());
}
}
}