module Plan
imports int
abstract syntax
Point = Point(abs:int, ord:int)
Comp = Line(p1:Point,p2:point)
| Triangle(p1:Point,p2:Point,p3:Point)
And we want to add a
import plan.types.*;
public class Carre implements jjtraveler.Visitable {
public Line l1;
public Line l2;
Carre(Line l1, Line l2) {
this.l1 = l1;
this.l2 = l2;
}
/* implements the Visitable interface */
public int getChildCount() { return 2; }
public jjtraveler.Visitable getChildAt(int index) {
switch(index) {
case 0: return l1;
case 1: return l2;
default: throw new IndexOutOfBoundsException();
}
}
public jjtraveler.Visitable setChildAt(int index, jjtraveler.Visitable v) {
switch(index) {
case 0: l1=(Line)v; return this;
case 1: l2=(Line)v; return this;
default: throw new IndexOutOfBoundsException();
}
}
}
public class CarreBasicStrategy extends plan.PlanBasicStrategy {
public CarreBasicStrategy(jjtraveler.reflective.VisitableVisitor v) {
super(v);
}
public jjtraveler.Visitable visit(jjtraveler.Visitable v)
throws jjtraveler.VisitFailure {
if (v instanceof Carre) {
return this.visit_Carre((Carre)v);
} else {
return super.visit(v);
}
}
public Carre visit_Carre(Carre arg) throws jjtraveler.VisitFailure {
return (Carre) any.visit(arg);
}
}