summaryrefslogtreecommitdiffstats
path: root/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticRunner.java
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticRunner.java
downloadStudium-master.tar.gz
Studium-master.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticRunner.java')
-rw-r--r--Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticRunner.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticRunner.java b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticRunner.java
new file mode 100644
index 0000000..4991041
--- /dev/null
+++ b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticRunner.java
@@ -0,0 +1,44 @@
+package net.sven_eisenhauer.swa_prakt1;
+
+public class ArithmeticRunner {
+
+ /**
+ * @param args
+ */
+ 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);
+ /*
+ try {
+ root.print();
+ System.out.println("\nResult: "+root.evaluate());
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ */
+ try {/*
+ ArithmeticIterator iter = new ExpressionIterator(root);
+ iter.print();
+ System.out.println("\n");
+ iter = new ExpressionIterator(root);
+ System.out.println("\nEvaluate: "+iter.evaluate()+"\n");
+ */
+ new PrintIter().traverse(root);
+ System.out.println("\n"+new EvalIter().traverse(root));
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+}