-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathState.java
More file actions
149 lines (112 loc) · 2.32 KB
/
State.java
File metadata and controls
149 lines (112 loc) · 2.32 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package Individual_Project;
import java.util.ArrayList;
import java.util.Objects;
/**
* The class State extends node
*/
public class State extends Node {
private double distance;
private double heuristic;
private ArrayList < State > path;
/**
*
* State
*
* @param x the x
* @param y the y
* @param path_movt the path_movt
* @param distance the distance
* @param < the <
* @return public
*/
public State(double x, double y, Path_movt path_movt, double distance, ArrayList < State > path) {
super(x, y, path_movt);
this.distance = distance;
this.heuristic = computeHeuristic();
this.path = path;
}
/**
*
* Gets the distance
*
* @return the distance
*/
public double getDistance() {
return distance;
}
/**
*
* Sets the distance
*
* @param distance the distance
*/
public void setDistance(double distance) {
this.distance = distance;
}
/**
*
* Gets the heuristic
*
* @return the heuristic
*/
public double getHeuristic() {
return heuristic;
}
/**
*
* Sets the heuristic
*
* @param heuristic the heuristic
*/
public void setHeuristic(double heuristic) {
this.heuristic = heuristic;
}
/**
*
* Gets the path
*
* @return the path
*/
public ArrayList < State > getPath() {
return path;
}
/**
*
* Sets the path
*
* @param < the <
*/
public void setPath(ArrayList < State > path) {
this.path = path;
}
@Override
/**
*
* To string
*
* @return String
*/
public String toString() {
return "State with x = " + getX() + " y = " + getY() + " path_movt id " + getPath_movt().getPath_movtId() + " path_movt name " + getPath_movt().getPath_movtName() +
" distance = " + distance + ", heuristic = " + heuristic;
}
/**
*
* Compute heuristic
*
* @return double
*/
public double computeHeuristic() {
return haversine(getY(), getX(), Air_Port_Values.client.getY(), Air_Port_Values.client.getX());
}
@Override
/**
*
* Hash code
*
* @return int
*/
public int hashCode() {
return Objects.hash(distance, heuristic);
}
}