The visitor pattern is depicted in LePus3 as shown in the picture below.

How does this diagram relate to the corresponding (Java) source code of the visitor pattern?

How do the artefacts in the diagram (client, Member, Ops, Elements, Aggregate, Visitors, square, triangle etc.) manifest themselves in the source code of the visitor pattern ?

enter image description here

没有正确的解决方案

其他提示

You can use code example from Wikipedia, where:

Class VisitorDemo is the Client rectangle.

Classes Wheel, Engine, Body, Car is elements triangle, and ICarElement is their abstract parent with void accept(ICarElementVisitor visitor); as Accept (abstract Visitor) oval.

Classes CarElementPrintVisitor, CarElementDoVisitor are at the same time Ops oval and Visitors triangle with

void visit(Wheel wheel);
void visit(Engine engine);
void visit(Body body);
void visit(Car car);

as Visit oval.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top