Änderungen am Binary Tree

This commit is contained in:
Johannes Theiner 2018-04-12 18:27:00 +02:00
parent 2ee19fc746
commit 1996730d1c
2 changed files with 7 additions and 0 deletions

View File

@ -11,4 +11,10 @@ public class Tree<T> {
public Node<T> getRoot() { public Node<T> getRoot() {
return root; return root;
} }
@Override
public boolean equals(Object obj) {
if(obj instanceof Tree) return root.equals(obj);
return false;
}
} }

View File

@ -28,5 +28,6 @@ public class VorlesungsTest {
assertEquals(Integer.valueOf(45), tree.getRoot().getValue()); assertEquals(Integer.valueOf(45), tree.getRoot().getValue());
assertEquals(Integer.valueOf(14), tree.getRoot().getLeft().getValue()); assertEquals(Integer.valueOf(14), tree.getRoot().getLeft().getValue());
assertEquals(Integer.valueOf(16), tree.getRoot().getRight().getValue()); assertEquals(Integer.valueOf(16), tree.getRoot().getRight().getValue());
assertEquals(new Node<Integer>(13, new Node<>(14), new Node<>(16)), new Node<Integer>(13, new Node<>(14), new Node<>(16)));
} }
} }