-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPollutionRule.pde
32 lines (28 loc) · 1.07 KB
/
PollutionRule.pde
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
class PollutionRule {
private int gatheringPollution;
private int eatingPollution;
/* initializes a new PollutionRule class with a specified pollution rate for gathering or eating sugar on a given square.
*/
public PollutionRule(int gatheringPollution, int eatingPollution) {
this.gatheringPollution = gatheringPollution;
this.eatingPollution = eatingPollution;
}
/* If s is not occupied, then does nothing.
* If an agent a is occupying s, then the pollution level of s is increased
* by eatingPollution points for every point of metabolism agent a has,
* and by gatheringPollution points for every point of sugar currently on s.
*/
public void pollute(Square s) {
if (s.getAgent() != null) {
s.setPollution(s.getPollution() + eatingPollution*s.getAgent().getMetabolism() + gatheringPollution*s.getSugar());
}
}
}
class PollutionRuleTester {
public void test() {
int gatheringPollution = 0;
int eatingPollution = 0;
PollutionRule pr = new PollutionRule(gatheringPollution, eatingPollution);
//stubbed
}
}