diff --git a/bin/app/App.class b/bin/app/App.class index 02d8341..1e30390 100644 Binary files a/bin/app/App.class and b/bin/app/App.class differ diff --git a/bin/app/BinaryNode.class b/bin/app/BinaryNode.class new file mode 100644 index 0000000..ddd4fa0 Binary files /dev/null and b/bin/app/BinaryNode.class differ diff --git a/bin/app/LinkedList.class b/bin/app/LinkedList.class new file mode 100644 index 0000000..5d92d4d Binary files /dev/null and b/bin/app/LinkedList.class differ diff --git a/bin/app/Node.class b/bin/app/Node.class new file mode 100644 index 0000000..ff48230 Binary files /dev/null and b/bin/app/Node.class differ diff --git a/src/app/App.java b/src/app/App.java index 49c5f22..7066605 100644 --- a/src/app/App.java +++ b/src/app/App.java @@ -3,20 +3,130 @@ package app; public class App { public static void main(String[] args) throws Exception { /** Aufgabe 1.1 - 1.3 */ - System.out.println("++++ Aufgabe 1.1 - 1.3 ++++"); - MyStack stack = new MyStack(); - stack.push("hello"); - stack.push("world"); - stack.push("123"); - System.out.println(stack.pop()); - System.out.println(stack.pop()); - System.out.println(stack.pop()); + // System.out.println("++++ Aufgabe 1.1 - 1.3 ++++"); + // MyStack stack = new MyStack(); + // stack.push("hello"); + // stack.push("world"); + // stack.push("123"); + // System.out.println(stack.pop()); + // System.out.println(stack.pop()); + // System.out.println(stack.pop()); - /** Aufgabe 1.4 */ - System.out.println("++++ Aufgabe 1.4 ++++"); - tokenizeAndCalc("( 2 + 3 )"); - tokenizeAndCalc("( 3 - ( 2 * 3 ) )"); - tokenizeAndCalc("( ( 5 * 4 ) - ( 2 * ( 3 / 4 ) ) )"); + // /** Aufgabe 1.4 */ + // System.out.println("++++ Aufgabe 1.4 ++++"); + // tokenizeAndCalc("( 2 + 3 )"); + // tokenizeAndCalc("( 3 - ( 2 * 3 ) )"); + // tokenizeAndCalc("( ( 5 * 4 ) - ( 2 * ( 3 / 4 ) ) )"); + + // /** Aufgabe 2.1 - 2.2 */ + // System.out.println("++++ Aufgabe 2.1 - 2.2 ++++"); + // Node n1 = new Node(); + // Node n2 = new Node(); + // Node n3 = new Node(); + // Node n4 = new Node(); + // n1.item = 1; + // n2.item = 2; + // n3.item = 3; + // n4.item = 4; + // n1.last = null; + // n1.next = n2; + // n2.last = n1; + // n2.next = n3; + // n3.last = n2; + // n3.next = n4; + // n4.last = n3; + // n4.next = null; + // n3.item = null; + // n2.next = n4; + // System.out.println(n1.item); + // System.out.println(n1.next.item); + // System.out.println(n1.next.next.item); + + /** Aufgabe 3.1 */ + System.out.println("++++ Aufgabe 3.1 ++++"); + BinaryNode ba1 = new BinaryNode(); + BinaryNode ba2 = new BinaryNode(); + BinaryNode ba3 = new BinaryNode(); + ba1.item = "+"; + ba2.item = "2"; + ba3.item = "3"; + ba2.parent = ba1; + ba3.parent = ba1; + ba1.left = ba2; + ba1.right = ba2; + + BinaryNode bb1 = new BinaryNode(); + BinaryNode bb2 = new BinaryNode(); + BinaryNode bb3 = new BinaryNode(); + BinaryNode bb4 = new BinaryNode(); + BinaryNode bb5 = new BinaryNode(); + bb1.item = "*"; + bb2.item = "5"; + bb3.item = "+"; + bb4.item = "2"; + bb5.item = "3"; + bb2.parent = bb1; + bb3.parent = bb1; + bb4.parent = bb3; + bb5.parent = bb3; + bb1.left = bb2; + bb1.right = bb3; + bb3.left = bb4; + bb3.left = bb5; + + BinaryNode bc1 = new BinaryNode(); + BinaryNode bc2 = new BinaryNode(); + BinaryNode bc3 = new BinaryNode(); + BinaryNode bc4 = new BinaryNode(); + BinaryNode bc5 = new BinaryNode(); + BinaryNode bc6 = new BinaryNode(); + BinaryNode bc7 = new BinaryNode(); + bc1.item = "+"; + bc2.item = "*"; + bc3.item = "2"; + bc4.item = "3"; + bc5.item = "*"; + bc6.item = "4"; + bc7.item = "5"; + bc2.parent = bc1; + bc3.parent = bc2; + bc4.parent = bc2; + bc5.parent = bc1; + bc6.parent = bc5; + bc7.parent = bc5; + bc1.left = bc2; + bc1.right = bc5; + bc2.left = bc3; + bc2.right = bc4; + bc5.left = bc6; + bc5.right = bc7; + + BinaryNode bd1 = new BinaryNode(); + BinaryNode bd2 = new BinaryNode(); + BinaryNode bd3 = new BinaryNode(); + BinaryNode bd4 = new BinaryNode(); + BinaryNode bd5 = new BinaryNode(); + BinaryNode bd6 = new BinaryNode(); + BinaryNode bd7 = new BinaryNode(); + bd1.item = "*"; + bd2.item = "2"; + bd3.item = "+"; + bd4.item = "3"; + bd5.item = "4"; + bd6.item = "*"; + bd7.item = "5"; + bd2.parent = bd1; + // bd3.parent = // Nicht möglich. Da Braum 3 Zweige benötigt. + + } + + private static boolean find(BinaryNode tree, String find) { + if (tree.item == find) + return true; + else { + // TODO: implement walk algorithm + return false || true; + } } private static void tokenizeAndCalc(String in) { diff --git a/src/app/BinaryNode.java b/src/app/BinaryNode.java new file mode 100644 index 0000000..2178b67 --- /dev/null +++ b/src/app/BinaryNode.java @@ -0,0 +1,8 @@ +package app; + +public class BinaryNode { + String item; + BinaryNode parent; + BinaryNode left; + BinaryNode right; +} \ No newline at end of file diff --git a/src/app/LinkedList.java b/src/app/LinkedList.java new file mode 100644 index 0000000..5ba7b3b --- /dev/null +++ b/src/app/LinkedList.java @@ -0,0 +1,5 @@ +package app; + +public class LinkedList { + // TODO: +} \ No newline at end of file diff --git a/src/app/Node.java b/src/app/Node.java new file mode 100644 index 0000000..39202e1 --- /dev/null +++ b/src/app/Node.java @@ -0,0 +1,7 @@ +package app; + +public class Node { + Item item; + Node next; + Node last; +} \ No newline at end of file