-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCell.java
More file actions
48 lines (42 loc) · 1.17 KB
/
Copy pathCell.java
File metadata and controls
48 lines (42 loc) · 1.17 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
import ecs100.*;
import java.awt.*;
import java.util.concurrent.ThreadLocalRandom;
/**
* This class handles an individual cell of the simulation
*
* @author Siôn Grabham-Madden
* @version 1
*/
public class Cell {
public String identity;
public int sideLength;
public int top;
public int left;
public int health;
public int reproductionVal;
/**
* Constructor
*/
public Cell(String iden, int x, int y) {
identity = iden;
sideLength = 2;
left = x;
top = y;
int randomNum = ThreadLocalRandom.current().nextInt(0, 100 + 1);
health = randomNum;
}
public void draw() {
if (identity.equals("empty")) {
UI.setColor(Color.black);
UI.fillRect(left,top,sideLength,sideLength);
}
else if (identity.equals("prey")) {
UI.setColor(Color.green);
UI.fillRect(left,top,sideLength,sideLength);
}
else if (identity.equals("predator")) {
UI.setColor(Color.red);
UI.fillRect(left,top,sideLength,sideLength);
}
}
}