-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.java
More file actions
102 lines (86 loc) · 1.61 KB
/
node.java
File metadata and controls
102 lines (86 loc) · 1.61 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
* The node class has an array of nodes
* this class is used to create a Digit tree
* <br><br>
* @author Allen McDermott
* @since 11/16/14
*/
public class node
{
//Data type String
String data;
//Parent Node
node parent;
//Pointer(s)
node[] nodeList = new node[11];
//contructor for a node
public node(String s,node p)
{
data = s+"";
parent = p;
}
/**@param sets the next node == input**/
public void setNext(String s,node elder)
{
if(s=="k") {
node k = new node(s,elder);
nodeList[10] = k;
}
else {
int index = Integer.parseInt(s);
node k = new node(s,elder);
nodeList[index] = k;
}
}
//@param int index the index of the no that will be set
public void setNode(int index) {
nodeList[index] = null;
}
//inList will see if the each index in nodeList is null
//@return false if every index is null true if not
public boolean inList() {
int j = 0;
for(int i = 0; i<nodeList.length;i++) {
if(nodeList[i]!=null){
j++;
}
}
if(j>0) {
return true;
}
else {
return false;
}
}
//noK() will see if each index is null except index 10
//@return false if all index's (we don't care about index #10) are null true if not
public boolean noK() {
int j = 0;
for(int i = 0; i<nodeList.length-1;i++) {
if(nodeList[i]!=null){
j++;
}
}
if(j>0) {
return true;
}
else {
return false;
}
}
/**@return the next InNode**/
public node getNext(int k)
{
return nodeList[k];
}
/**@return data of the node**/
public String getData()
{
return data;
}
/**@return parent node**/
public node getParent()
{
return parent;
}
}