From 85ac78adf5994764c1cc184713ddc1700c5dc718 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Thu, 12 Apr 2018 18:52:14 +0200 Subject: [PATCH] =?UTF-8?q?so,=20jetzt=20sollte=20wieder=20alles=20gr?= =?UTF-8?q?=C3=BCn=20sein?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../de/joethei/hs/java2/vorlesungen/binaryTree/Node.java | 7 ++++++- .../java/de/joethei/hs/java2/tests/VorlesungsTest.java | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) 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