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

            visitable.Accept(visitor);
            Console.WriteLine("{0} area: {1}", visitable.GetType().Name, visitor.Area);
        }
Example #2
0
        static void CalculateTotalArea(IEnumerable <IAmVisitable> visitables)
        {
            var visitor = new AreaCalculationVisitor();

            foreach (var visitable in visitables)
            {
                visitable.Accept(visitor);
            }
            Console.WriteLine("Total area: {0}", visitor.Area);
        }