class Compound : Shape
{
protected List<Shape> shapes;
public Compound()
{
shapes = new List<Shape>();
position = new Point(10000, 10000);
}
public void CalculatePosition()
{
int intLeftMostPoint = shapes[0].GetLeftMostPoint;
int intTopMostPoint = shapes[0].GetTopMostPoint;
foreach (Shape sh in shapes)
{
intLeftMostPoint = sh.GetLeftMostPoint();
intTopMostPoint = sh.GetTopMostPoint();
if (intLeftMostPoint < this.X)
{
this.position = new Point(intLeftMostPoint, this.Y);
}
if (intTopMostPoint < this.Y)
{
this.position = new Point(this.X, intTopMostPoint);
}
}
}