diff --git a/src/main/java/de/joethei/hs/java2/vorlesungen/binaryTree/Node.java b/src/main/java/de/joethei/hs/java2/vorlesungen/binaryTree/Node.java index 0ea3487..b74dcd7 100644 --- a/src/main/java/de/joethei/hs/java2/vorlesungen/binaryTree/Node.java +++ b/src/main/java/de/joethei/hs/java2/vorlesungen/binaryTree/Node.java @@ -1,11 +1,15 @@ package de.joethei.hs.java2.vorlesungen.binaryTree; +import java.util.logging.Logger; + public class Node { private T value; private Node left; private Node right; + private Logger logger = Logger.getLogger(getClass().getName()); + public Node() { } @@ -38,8 +42,9 @@ public class Node { @Override public boolean equals(Object obj) { - if(obj instanceof Node) { + if (obj instanceof Node) { Node node = (Node) obj; + if(node.value.equals(this.value) && node.left == null && node.right == null) return true; return node.value.equals(this.value) && node.left.equals(this.left) && node.right.equals(this.right); } return false; diff --git a/src/test/java/de/joethei/hs/java2/tests/VorlesungsTest.java b/src/test/java/de/joethei/hs/java2/tests/VorlesungsTest.java index 3cf05d8..7d227c7 100644 --- a/src/test/java/de/joethei/hs/java2/tests/VorlesungsTest.java +++ b/src/test/java/de/joethei/hs/java2/tests/VorlesungsTest.java @@ -25,9 +25,11 @@ public class VorlesungsTest { Tree tree = new Tree<>(new Node<>(45, new Node<>(14), new Node<>(16))); + Node node = new Node<>(45, new Node<>(14), new Node<>(16)); assertEquals(Integer.valueOf(45), tree.getRoot().getValue()); assertEquals(Integer.valueOf(14), tree.getRoot().getLeft().getValue()); assertEquals(Integer.valueOf(16), tree.getRoot().getRight().getValue()); - assertEquals(new Node(13, new Node<>(14), new Node<>(16)), new Node(13, new Node<>(14), new Node<>(16))); + + assertEquals(tree.getRoot(), node); } } \ No newline at end of file