Skip to content

Commit 65749bd

Browse files
committed
attribute visibility
1 parent 0dda9e7 commit 65749bd

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed
Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
package example;
2-
import java.util.LinkedList;
3-
import java.util.List;
4-
5-
public class TreeNode<T> {
6-
7-
T data;
8-
TreeNode<T> parent;
9-
List<TreeNode<T>> children;
10-
11-
public List<TreeNode<T>> getChildren() {
12-
return children;
13-
}
14-
15-
public TreeNode<T> getParent() {
16-
return parent;
17-
}
18-
19-
public T getData() {
20-
return data;
21-
}
22-
23-
public TreeNode(T data) {
24-
this.data = data;
25-
this.children = new LinkedList<TreeNode<T>>();
26-
}
27-
28-
public TreeNode(TreeNode<T> n) {
29-
this.data = n.getData();
30-
this.children = n.getChildren();
31-
}
32-
33-
public TreeNode<T> addChild(T child) {
34-
TreeNode<T> childNode = new TreeNode<T>(child);
35-
childNode.parent = this;
36-
this.children.add(childNode);
37-
return childNode;
38-
}
39-
40-
}
1+
package example;
2+
import java.util.LinkedList;
3+
import java.util.List;
4+
5+
public class TreeNode<T> {
6+
7+
private T data;
8+
private TreeNode<T> parent;
9+
private List<TreeNode<T>> children;
10+
11+
public List<TreeNode<T>> getChildren() {
12+
return children;
13+
}
14+
15+
public TreeNode<T> getParent() {
16+
return parent;
17+
}
18+
19+
public T getData() {
20+
return data;
21+
}
22+
23+
public TreeNode(T data) {
24+
this.data = data;
25+
this.children = new LinkedList<TreeNode<T>>();
26+
}
27+
28+
public TreeNode(TreeNode<T> n) {
29+
this.data = n.getData();
30+
this.children = n.getChildren();
31+
}
32+
33+
public TreeNode<T> addChild(T child) {
34+
TreeNode<T> childNode = new TreeNode<T>(child);
35+
childNode.parent = this;
36+
this.children.add(childNode);
37+
return childNode;
38+
}
39+
40+
}

0 commit comments

Comments
 (0)