public void AddShape(Shape shape, int adjust) { shape.X += adjust; if (!TryAttachShape(shape)) { shapes.Add(shape); } }
public override bool HorizontallyTranslates(Shape shape) { throw new NotImplementedException(); }
public abstract bool HorizontallyTranslates(Shape shape);
public bool Contains(Shape shape) { return shapes.Exists(s => s.HorizontallyTranslates(shape)); }
protected bool TryAttachShape(Shape shape) { bool isAttached = false; if (shape is HalfCircle) { HalfCircle halfCircle = (HalfCircle)shape; int matchIndex = shapes.FindIndex(s => s is HalfCircle && AreTwoHalfCirclesACircle(halfCircle, (HalfCircle)s)); if (matchIndex != -1) { isAttached = true; shapes[matchIndex] = new Circle(halfCircle.CX, halfCircle.CY, halfCircle.Radius); } } return isAttached; }
public override bool HorizontallyTranslates(Shape shape) { if (ShapeType != shape.ShapeType) return false; return Y == shape.Y && Radius == ((HalfCircle)shape).Radius; }