
public class Rechne {
	int rechne(Zahl z){return z.n;}
	int rechne(Mult m){		
		return rechne(m.op1)*rechne(m.op2);
	}
	int rechne(Add m){		
		return rechne(m.op1)+rechne(m.op2);
	}
	int rechne(Knoten n){	
		if (n instanceof Zahl) {
			return rechne((Zahl) n);
		}if (n instanceof Mult) {
			return rechne((Mult) n);
		}if (n instanceof Add) {
			return rechne((Add) n);	
		}
		throw new RuntimeException("unbekommenter Knotentyp");
	}

}
