-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.java
40 lines (33 loc) · 835 Bytes
/
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
import java.util.LinkedList;
public class Node {
int index;
//keeps track of the index of the edges
LinkedList<Node> edges = new LinkedList<Node>();
public int edge =0;
// to help you keep track of things as you're solving the maze
boolean visited = false;
boolean inSolution = false;
// these are just here to help with the toString method
static final String PATH = "X";
static final String VISIT = ".";
static final String NOT_VISIT = " ";
public String toString() {
if(visited) {
if(inSolution) return PATH;
else return VISIT;
}
else return NOT_VISIT;
}
public Node(int i) {
index = i;
}
public Node hasUnvisitedEdge() {
for(int i = 0; i<edges.size();i++) {
if(!edges.get(i).visited) {
return edges.get(i);
}
edge++;
}
return null;
}
}