Exemplo n.º 1
0
        static void PrintArea(Shape a_shape)
        {
            ShapeVisitor v = new ConsolePrintShapeVisitor();

            a_shape.Accept(v);

            System.Console.WriteLine("Area is: {0}", a_shape.GetArea());
        }
Exemplo n.º 2
0
 /**
  * Add a shape to this shape.
  *
  * @param shape
  *            The shape to add
  * @throws ShapeDoesNotSupportChildren
  *             if this shape is not a composite
  */
 public void AddShape(Shape shape)
 {
     // TODO: Implement
     if (AsComposite() != null)
     {
         AsComposite().shapes.Add(shape);
     }
     else
     {
         throw new ShapeDoesNotSupportChildren();
     }
 }
Exemplo n.º 3
0
 /**
  * Remove a shape from this shape childrens
  *
  * @param shape
  *            the shape to remove
  * @return true if the shape was present and was removed, false if the shape
  *         was not present
  */
 public bool removeShape(Shape shape)
 {
     if (GetShapes().IndexOf(shape)>=0)
     {
         GetShapes().RemoveAt(GetShapes().IndexOf(shape));
         return true;
     }
     return false;
 }
 public void Add(Shape a_child)
 {
     m_shapes.Add(a_child);
 }