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

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