









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










1
3
public interface Node { } public class Number extends Node { public int n; } public class Plus extends Node { public Node left; public Node right; }
public interface Node { public int sum(); } public class Number extends Node { public int n; public int sum() { return n; } } public class Plus extends Node{ public Node left; public Node right; public int sum() { return left.sum() + right.sum(); } }
7
9
13
public interface Node { public void accept(Visitor v); } public class Number extends Node { … public void accept(Visitor v) {v.visitNumber(this);} } public class Plus extends Node { … public void accept(Visitor v) {v.visitPlus(this);} }
15
19
21
25
27