static void CalculateArea(IAmVisitable visitable) { var visitor = new AreaCalculationVisitor(); visitable.Accept(visitor); Console.WriteLine("{0} area: {1}", visitable.GetType().Name, visitor.Area); }
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); }