summaryrefslogtreecommitdiffstats
path: root/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/PrintIter.java
blob: 90d43d94ba3d12d431cd8ade6cc89313b5d5180c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package net.sven_eisenhauer.swa_prakt1;

public class PrintIter implements ExpIter {

	@Override
	public Number traverse(ArithmeticExpression exp) {
		if(exp instanceof ArithmeticVariable) {
			System.out.print(((ArithmeticVariable) exp).getName());
		} else {
			ArithmeticOperation actOp = (ArithmeticOperation) exp;
			System.out.print("(");
			traverse(actOp.getLeftOperand());
			System.out.print(actOp.getOperationSign());
			traverse(actOp.getRightOperand());
			System.out.print(")");
		}
		return 0;
	}
}