Exemple #1
0
        static void CalculateArea(IAmVisitable visitable)
        {
            var visitor = new AreaCalculationVisitor();

            visitable.Accept(visitor);
            Console.WriteLine("{0} area: {1}", visitable.GetType().Name, visitor.Area);
        }
Exemple #2
0
        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);
        }