The VISITOR Pattern
Solution
- Define a visitor interface type that has methods for visiting
elements of each of the given types.
- Each element class defines an accept method that invokes the
matching element visitation method on the visitor parameter.
- To implement an operation, define a class that implements the
visitor interface type and supplies the operation s action for each
element type.