-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cell.java
56 lines (44 loc) · 1.76 KB
/
Cell.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
53
54
55
56
public class Cell
{
private Macro macrophage;
private Bact bacterium;
private int row; //perhaps redundant
private int col;
public double resource;
private double growthRate;
private double maxResource;
public double timeLastDepleted;
public Cell(int row, int col, double res, double rate, double max)
{
this.row = row;
this.col = col;
this.macrophage = null;
this.bacterium = null;
this.resource = res;
this.growthRate = rate;
this.maxResource = max;
}
public void occupy(Agent a){
if(a instanceof Macro)
occupy((Macro)a);
if(a instanceof Bact)
occupy((Bact)a);
}
public void occupy(Macro m) {macrophage = m; m.setRowCol(row,col); }
public void occupy(Bact b) { bacterium = b; b.setRowCol(row,col); }
public Macro removeMacrophage() { macrophage.setRowCol(-1,-1); Macro tmp = macrophage; macrophage = null; return(tmp); }
public Bact removeBacterium() { bacterium.setRowCol(-1,-1); Bact tmp = bacterium; bacterium = null; return(tmp); }
public int getRow() { return row; }
public int getCol() { return col; }
public Macro getMacrophage() { return(macrophage); }
public Bact getBacterium() { return(bacterium); }
public boolean isOccupied() { return(macrophage != null || bacterium != null); }
public boolean hasMacrophage() {return(macrophage != null); }
public boolean hasBacterium() {return(bacterium != null); }
public double getResource(){ return resource; }
public void setResource(double res) { resource = res; }
public double getRate(){ return growthRate; }
public double getTimeLastDepleted(){ return timeLastDepleted; }
public void setTimeLastDepleted(double t) { timeLastDepleted = t; }
public String toString() { return("(" + row + "," + col + ")"); }
}