class ShapeGroup var _shapes = List() get shapes from var class Shape is abstract pass class Circle inherits Shape pass class Rectangle inherits Shape pass class Square inherits Rectangle pass class WriteShapeXmlVisitor inherits Visitor var _tw as TextWriter cue init(tw as TextWriter) base.init _tw = tw get methodName as String is override return 'write' def write(obj as Object?) if obj is nil, return _tw.writeLine('Unbound visitation for type [obj.getType]') def write(group as ShapeGroup) _tw.writeLine('') for shape in group.shapes .dispatch(shape) _tw.writeLine('') def write(rect as Rectangle) _tw.writeLine('') def write(square as Square) _tw.writeLine('') # forgot to handle Circle on purpose class Test def main is shared group = ShapeGroup() group.shapes.addRange([Square(), Circle(), Rectangle()]) sw = StringWriter() WriteShapeXmlVisitor(sw).write(group) assert sw.toString.trim.replace('\r', '').replace('\n', '; ') == '; ; Unbound visitation for type Circle; ; '