-
Notifications
You must be signed in to change notification settings - Fork 11
/
Node.java
90 lines (69 loc) · 1.72 KB
/
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
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
import java.util.ArrayList;
public class Node {
private boolean visited;
private String state;
private ArrayList<Node> children;
private Node parent;
private int cost;
private int estimatedCostToGoal;
private int totalCost;
private int depth;
public int getDepth() {
return depth;
}
public void setDepth(int depth) {
this.depth = depth;
}
public boolean isVisited() {
return visited;
}
public void setVisited(boolean visited) {
this.visited = visited;
}
public int getTotalCost() {
return totalCost;
}
public void setTotalCost(int totalCost) {
this.totalCost = totalCost;
}
public void setTotalCost(int cost, int estimatedCost) {
this.totalCost = cost + estimatedCost;
}
public int getEstimatedCostToGoal() {
return estimatedCostToGoal;
}
public void setEstimatedCostToGoal(int estimatedCostToGoal) {
this.estimatedCostToGoal = estimatedCostToGoal;
}
public int getCost() {
return cost;
}
public void setCost(int cost) {
this.cost = cost;
}
public void setState(String state) {
this.state = state;
}
public Node getParent() {
return parent;
}
public void setParent(Node parent) {
this.parent = parent;
}
// Constructor
public Node(String state) {
this.state = state;
children = new ArrayList<Node>();
}
// Properties
public String getState() {
return state;
}
public ArrayList<Node> getChildren() {
return children;
}
// Public interface
public void addChild(Node child) {
children.add(child);
}
}