static void CalculateArea(IAmVisitable visitable) { var visitor = new AreaCalculationVisitor(); visitable.Accept(visitor); Console.WriteLine("{0} area: {1}", visitable.GetType().Name, visitor.Area); }
static void CalculateDrawingArea(IAmVisitable visitable) { var visitor = new DrawingAreaCalculationVisitor(); visitable.Accept(visitor); var rect = visitor.Rect; Console.WriteLine("Drawing area for {0}: ({1},{2}) ({3},{4})", visitable.GetType().Name, rect.Left, rect.Top, rect.Right, rect.Bottom); }