-
Notifications
You must be signed in to change notification settings - Fork 0
/
Giant.java
32 lines (26 loc) · 996 Bytes
/
Giant.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
import java.awt.*;
public class Giant extends Critter {
private double moves = 0;
public Giant() {
}
public Action getMove(CritterInfo info) {
if (info.getFront() == Neighbor.OTHER) { return Action.INFECT; }
else if (info.getFront() == Neighbor.EMPTY) { return Action.HOP; }
else { return Action.RIGHT; }
}
public Color getColor() {
return Color.GRAY;
}
public String toString() {
incMove();
if ((this.moves / 6) <= 1) { return "fee"; }
else if (((this.moves / 6) > 1) && ((this.moves / 6) <= 2)) { return "fie"; }
else if (((this.moves / 6) > 2) && ((this.moves / 6) <= 3)) { return "foe"; }
else if (((this.moves / 6) > 3) && ((this.moves / 6) <= 4)) { return "fum"; }
else { throw new IllegalArgumentException(); }
}
public void incMove() {
if ((this.moves / 6) >= 4) { this.moves = 1; }
else { this.moves++; }
}
}