namespace VisitorWithOOP { interface IVisitor { visitPanel ( panel ) : void ; visitLabel ( label ) : void ; visitButton ( button ) : void ; } class Renderer implements IVisitor { visitPanel ( panel ) { } visitLabel ( label ) { } visitButton ( button ) { } } class XmlSerializer implements IVisitor { visitPanel ( panel ) { } visitLabel ( label ) { } visitButton ( button ) { } } interface IUIWidget { accept ( visitor ) : void ; } class Panel implements IUIWidget { accept ( visitor ) { visitor . visitPanel ( this ) ; } } class Label implements IUIWidget { accept ( visitor ) { visitor . visitLabel ( this ) ; } } class Button implements IUIWidget { accept ( visitor ) { visitor . visitButton ( this ) ; } } }