Beispiel #1
0
 public void AddShape(Shape shape, int adjust)
 {
     shape.X += adjust;
     if (!TryAttachShape(shape))
     {
         shapes.Add(shape);
     }
 }
Beispiel #2
0
 public override bool HorizontallyTranslates(Shape shape)
 {
     throw new NotImplementedException();
 }
Beispiel #3
0
 public abstract bool HorizontallyTranslates(Shape shape);
Beispiel #4
0
 public bool Contains(Shape shape)
 {
     return shapes.Exists(s => s.HorizontallyTranslates(shape));
 }
Beispiel #5
0
        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;
        }
Beispiel #6
0
        public override bool HorizontallyTranslates(Shape shape)
        {
            if (ShapeType != shape.ShapeType) return false;

            return Y == shape.Y && Radius == ((HalfCircle)shape).Radius;
        }