-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHexVertex.java
52 lines (47 loc) · 1.04 KB
/
HexVertex.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
import java.awt.Color;
import javalib.worldimages.*;
class HexVertex {
Posn pos;
HexVertex top;
HexVertex topLeft;
HexVertex bottomLeft;
HexVertex bottom;
HexVertex bottomRight;
HexVertex topRight;
boolean processed;
boolean onPath;
HexVertex(Posn pos) {
this.pos = pos;
this.top = this;
this.topLeft = this;
this.bottomLeft = this;
this.bottom = this;
this.bottomRight = this;
this.topRight = this;
this.processed = false;
this.onPath = false;
}
// to determine if two vertexes are equal
public boolean equals(Object o) {
if (o instanceof HexVertex) {
HexVertex that = (HexVertex) o;
return this.pos.equals(that.pos);
}
else {
return false;
}
}
// hashCode
public int hashCode() {
return this.pos.hashCode();
}
// determines color of player
public Color color() {
if (this.onPath) {
return new Color(40, 110, 220);
}
else {
return new Color(100, 160, 250);
}
}
}