- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
Latest commit
40 lines (33 loc) · 835 Bytes
/
Copy pathNode.java
File metadata and controls
40 lines (33 loc) · 835 Bytes
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
importjava.util.LinkedList;
publicclassNode {
intindex;
//keeps track of the index of the edges
LinkedList<Node> edges = newLinkedList<Node>();
publicintedge =0;
// to help you keep track of things as you're solving the maze
booleanvisited = false;
booleaninSolution = false;
// these are just here to help with the toString method
staticfinalStringPATH = "X";
staticfinalStringVISIT = ".";
staticfinalStringNOT_VISIT = " ";
publicStringtoString() {
if(visited) {
if(inSolution) returnPATH;
elsereturnVISIT;
}
elsereturnNOT_VISIT;
}
publicNode(inti) {
index = i;
}
publicNodehasUnvisitedEdge() {
for(inti = 0; i<edges.size();i++) {
if(!edges.get(i).visited) {
returnedges.get(i);
}
edge++;
}
returnnull;
}
}