-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimidCritter.java
More file actions
50 lines (45 loc) · 1.15 KB
/
Copy pathTimidCritter.java
File metadata and controls
50 lines (45 loc) · 1.15 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
/* CRITTERS Main.java
* EE422C Project 5 submission by
* Anthony Bauer
* amb6869
* 16480
* Grant Uy
* gau84
* 16480
* Slip days used: <0>
* Fall 2016
*/
package assignment5;
import javafx.scene.paint.Color;
/**
* TimidCritter avoids all interactions with other critters, except with algae.
* TimidCritter invokes the look method to check to make sure it's not walking onto another critter.
* It will only fight with algae, won't flee, and never reproduces.
*/
public class TimidCritter extends Critter {
@Override
public CritterShape viewShape() {
return CritterShape.STAR;
}
@Override
public javafx.scene.paint.Color viewColor() {
return Color.CHOCOLATE;
}
@Override
public String toString() {
return "T";
}
public boolean fight(String opponent) {
return opponent.equals("@");
}
@Override
public void doTimeStep() {
int direction;
String lookResult;
do {
direction = Critter.getRandomInt(8);
lookResult = look(direction, false);
} while (lookResult != null && !lookResult.equals("@"));
walk(direction);
}
}