-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVertex.java
48 lines (43 loc) · 893 Bytes
/
Vertex.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
import java.awt.Color;
import javalib.worldimages.*;
class Vertex {
Posn pos;
Vertex top;
Vertex left;
Vertex bottom;
Vertex right;
boolean processed;
boolean onPath;
Vertex(Posn pos) {
this.pos = pos;
this.top = this;
this.left = this;
this.bottom = this;
this.right = this;
this.processed = false;
this.onPath = false;
}
// to determine if two vertexes are equal
public boolean equals(Object o) {
if (o instanceof Vertex) {
Vertex that = (Vertex) o;
return this.pos.equals(that.pos);
}
else {
return false;
}
}
// hashCode
public int hashCode() {
return this.pos.hashCode();
}
// color
public Color color() {
if (this.onPath) {
return new Color(40, 110, 220);
}
else {
return new Color(100, 160, 250);
}
}
}