Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Visitor
class WidthVisitor implements BoxVisitor {
int visitBob(BobBox box) {
return box.getWidth();
}
int visitAlice(AliceBox box) {
return Math.abs(box.getX2() - box.getX1());
}
}
class HeightVisitor implements BoxVisitor {
int visitBob(BobBox box) {
return box.getHeight();
}
int visitAlice(AliceBox box) {
return Math.abs(box.getY2() - box.getY1());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.