diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Main.java | |
| download | Studium-master.tar.gz Studium-master.tar.bz2 | |
Diffstat (limited to 'Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Main.java')
| -rw-r--r-- | Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Main.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Main.java b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Main.java new file mode 100644 index 0000000..919baaa --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Main.java @@ -0,0 +1,26 @@ +package swa.prakt3; + +public class Main { + + public static void main(String[] args) { + ArithmeticVariable a = new ArithmeticVariable("a", 2); + ArithmeticVariable b = new ArithmeticVariable("b", 77); + ArithmeticVariable c = new ArithmeticVariable("c", 0.1); + ArithmeticVariable d = new ArithmeticVariable("d", 0.00003); + + ArithmeticExpression aAddb = new ArithmeticAddition(a,b); + ArithmeticExpression aSubc = new ArithmeticSubstraction(a,c); + ArithmeticExpression bMuld = new ArithmeticMultiplication(b, d); + + ArithmeticExpression ae1 = new ArithmeticMultiplication(aAddb, aSubc); + ArithmeticExpression ae2 = new ArithmeticSubstraction(bMuld, a); + + ArithmeticExpression root = new ArithmeticAddition(ae1, ae2); + + Iterator iter = new Iterator(); + iter.traverse(root, new PrintVisitor()); + System.out.println(); + System.out.println(iter.traverse(root, new EvalVisitor())); + } + +} |
