summaryrefslogtreecommitdiffstats
path: root/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticRunner.java
blob: b3372f4fcc9ea59c479899c803caac6cd6554983 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package net.sven_eisenhauer.swa_prakt1;

public class ArithmeticRunner {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ArithmeticVariable a = new ArithmeticVariable("a", 2L);
		ArithmeticVariable b = new ArithmeticVariable("b", 77);
		ArithmeticVariable c = new ArithmeticVariable("c", 0.1f);
		ArithmeticVariable d = new ArithmeticVariable("d", 0.00003d);
		
		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 ae3 = new ArithmeticDivision(new ArithmeticAddition(ae1, ae2),new ArithmeticVariable("e", 100000));
		
		try {
			ae3.print();
			System.out.println("\nResult: "+ae3.evaluate());
		} catch (Throwable t) {
			t.printStackTrace();
		}
		
	}

}