Abstract classes, Interfaces, and Patterns
- slide 35 : 37
Towards a Visitor solution
The transition from natural object-oriented traversals to
Visitor
Steps:
A
Visitor
interface and three concrete Visitor classes are defined
The
Intsequence
classes are refactored - the traversal methods are moved to the visitor classes
Accept
methods are defined in the
IntSequence
classes.
Accept
takes a
Visitor
as parameter
Accept
passes
this
to the visitor, which in turn may activate
Accept
on components
Try the accompanying
SVG animation