-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.java
64 lines (53 loc) · 1.25 KB
/
Node.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* Created by Jimmy Pham and Ward Bradt
* @param <T>
*/
public class Node<T> {
private T contents;
private Node<T> parent;
private Node<T> left;
private Node<T> right;
public Node() {
contents = null;
left = null;
right = null;
parent = null;
}
public Node(T item) {
contents = item;
left = null;
right = null;
parent = null;
}
/**
* Copy constructor
*
* @param copiedRoot the Node that is being copied
*/
public Node(Node<T> copiedRoot) {
contents = copiedRoot.getContents();
left = copiedRoot.getLeft();
right = copiedRoot.getRight();
parent = copiedRoot.getParent();
}
public T getContents() {
return contents;
}
public void setContents(T item) { contents = item; }
public void setParent(Node<T> p) { parent = p; }
public Node<T> getParent() { return parent; }
public Node<T> getLeft() {
return left;
}
public Node<T> getRight() {
return right;
}
public void setLeft(Node<T> item) {
item.setParent(this);
left = item;
}
public void setRight(Node<T> item) {
item.setParent(this);
right = item;
}
}