Compare commits
	
		
			2 Commits 
		
	
	
		
			993b91d671
			...
			8a11dbf1b8
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 8a11dbf1b8 | |
|  | d4b9dc25f2 | 
|  | @ -0,0 +1,19 @@ | ||||||
|  | 
 | ||||||
|  | public class Calculator { | ||||||
|  | 
 | ||||||
|  | 	Node<Symbol> erzeugeBeispielBaum() { | ||||||
|  | 	 | ||||||
|  | 		Node<Symbol> root = new Node<Symbol>(new Symbol("+")); | ||||||
|  | 		 | ||||||
|  | 		root.left = new Node<Symbol>(new Symbol("3")); | ||||||
|  | 		 | ||||||
|  | 		root.right = new Node<Symbol>(new Symbol("*")); | ||||||
|  | 		 | ||||||
|  | 		root.right.left = new Node<Symbol>(new Symbol("5")); | ||||||
|  | 		 | ||||||
|  | 		root.right.right = new Node<Symbol>(new Symbol("8")); | ||||||
|  | 	 | ||||||
|  | 		return root; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
|  | @ -15,4 +15,16 @@ public class Symbol { | ||||||
| 	public boolean istPlus() { | 	public boolean istPlus() { | ||||||
| 		return s == "+"; | 		return s == "+"; | ||||||
| 	} | 	} | ||||||
|  | 	 | ||||||
|  | 	public boolean istOperator() { | ||||||
|  | 		return istPlus() || istMal(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public boolean istZahl() { | ||||||
|  | 		return !istOperator(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public int getInt() { | ||||||
|  | 		return Integer.parseInt(s); | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -0,0 +1,11 @@ | ||||||
|  | 
 | ||||||
|  | public class Test { | ||||||
|  | 
 | ||||||
|  | 	public static void main(String[] args) { | ||||||
|  | 		 | ||||||
|  | 		Calculator c = new Calculator(); | ||||||
|  | 		 | ||||||
|  | 		Node<Symbol> root = c.erzeugeBeispielBaum(); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue