From 1996730d1ca9a3a6b812b210b18e2fe206ec0195 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Thu, 12 Apr 2018 18:27:00 +0200 Subject: [PATCH] =?UTF-8?q?=C3=84nderungen=20am=20Binary=20Tree?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../de/joethei/hs/java2/vorlesungen/binaryTree/Tree.java | 6 ++++++ src/test/java/de/joethei/hs/java2/tests/VorlesungsTest.java | 1 + 2 files changed, 7 insertions(+) diff --git a/src/main/java/de/joethei/hs/java2/vorlesungen/binaryTree/Tree.java b/src/main/java/de/joethei/hs/java2/vorlesungen/binaryTree/Tree.java index 380691b..95d6b6d 100644 --- a/src/main/java/de/joethei/hs/java2/vorlesungen/binaryTree/Tree.java +++ b/src/main/java/de/joethei/hs/java2/vorlesungen/binaryTree/Tree.java @@ -11,4 +11,10 @@ public class Tree { public Node getRoot() { return root; } + + @Override + public boolean equals(Object obj) { + if(obj instanceof Tree) return root.equals(obj); + return false; + } } \ No newline at end of file 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 198b7be..3cf05d8 100644 --- a/src/test/java/de/joethei/hs/java2/tests/VorlesungsTest.java +++ b/src/test/java/de/joethei/hs/java2/tests/VorlesungsTest.java @@ -28,5 +28,6 @@ public class VorlesungsTest { 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))); } } \ No newline at end of file