-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNode.java
More file actions
70 lines (52 loc) · 1.14 KB
/
Node.java
File metadata and controls
70 lines (52 loc) · 1.14 KB
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
65
66
67
68
69
70
package gp_project;
public class Node {
private String m_data; // root data
private Node m_leftNode;
private Node m_rightNode;
private NodeType m_type;
public Node(Node other) {
this.m_type = other.getNodeType();
this.m_data = other.getData();
this.m_rightNode = other.getRightNode();
this.m_leftNode = other.getLeftNode();
}
public Node(String data, NodeType type) {
m_data = data;
m_type = type;
}
public String getData() {
return m_data;
}
public Node getLeftNode() {
return m_leftNode;
}
public NodeType getNodeType() {
return m_type;
}
public Node getRightNode() {
return m_rightNode;
}
public void printNode() {
System.out.format("node data: %s\n", m_data);
if (m_rightNode != null) {
System.out.println("rightnode:");
m_rightNode.printNode();
}
if (m_leftNode != null) {
System.out.println("leftnode:");
m_leftNode.printNode();
}
}
public void setData(String data) {
m_data = data;
}
public void setLeftNode(Node node) {
m_leftNode = node;
}
public void setNodeType(NodeType type) {
m_type = type;
}
public void setRightNode(Node node) {
m_rightNode = node;
}
}