so, jetzt sollte wieder alles grün sein
This commit is contained in:
parent
1996730d1c
commit
85ac78adf5
|
@ -1,11 +1,15 @@
|
|||
package de.joethei.hs.java2.vorlesungen.binaryTree;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Node<T> {
|
||||
|
||||
private T value;
|
||||
private Node<T> left;
|
||||
private Node<T> right;
|
||||
|
||||
private Logger logger = Logger.getLogger(getClass().getName());
|
||||
|
||||
public Node() {
|
||||
}
|
||||
|
||||
|
@ -38,8 +42,9 @@ public class Node<T> {
|
|||
|
||||
@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;
|
||||
|
|
|
@ -25,9 +25,11 @@ public class VorlesungsTest {
|
|||
|
||||
|
||||
Tree<Integer> tree = new Tree<>(new Node<>(45, new Node<>(14), new Node<>(16)));
|
||||
Node<Integer> 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<Integer>(13, new Node<>(14), new Node<>(16)), new Node<Integer>(13, new Node<>(14), new Node<>(16)));
|
||||
|
||||
assertEquals(tree.getRoot(), node);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue