-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathState.java
More file actions
68 lines (52 loc) · 1.24 KB
/
State.java
File metadata and controls
68 lines (52 loc) · 1.24 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
package server_side;
import java.util.ArrayList;
public class State {
private int row;
private int col;
private int cost; // cost to reach this state
private State Father; // the state we came from to this state
ArrayList<State> ListOfChildren; // list of the neighbors states
public State(int row,int col,int cost){ // CTOR
this.col=col;
this.row=row;
this.cost=cost;
this.ListOfChildren=new ArrayList<State>();
}
public boolean equals(State s){ // it’s easier to simply overload
if(this.col==s.col && this.row==s.row) {return true;}
return false;
}
public int getCost() {
return cost;
}
public void setCost(int d) {
this.cost = d;
}
public State getFather() {
return Father;
}
public void setFather(State father) {
Father = father;
}
public void setCameFrom(State n) {
this.Father = n;
}
public int getRow() {
return this.row;
}
public void setRow(int row) {
this.row = row;
}
public int getCol() {
return this.col;
}
public void setCol(int col) {
this.col = col;
}
public void addtoListOfChildren(State s) {
this.ListOfChildren.add(s);
}
public ArrayList<State> getListofniebors() {
return this.ListOfChildren;
}
}