-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCasual.java
55 lines (43 loc) · 1.31 KB
/
Casual.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
package isp;
/**
* @author Ethan Gruening
* Models a Casual user within a town, based upon the Town Cell type
*/
public class Casual extends TownCell{
public Casual(Town p, int r, int c) {
super(p, r, c);
}
@Override
public State who() {
return State.CASUAL;
}
@Override
public TownCell next(Town tNew) {
//The next Cell
TownCell newCell;
//Checks first additional rule
if(nCensus[EMPTY] + nCensus[OUTAGE] <=1){
newCell = new Reseller(tNew, row, col);
}
//checks if it has a reseller as a neighbor and causes an outage
else if(nCensus[RESELLER] > 0){
newCell = new Outage(tNew, row, col);
}
//Checks if it has streamer as a neighbor and makes new streamer
else if (nCensus[STREAMER] > 0){
newCell = new Streamer(tNew, row, col);
}
//Checks additional rules
else if(nCensus[CASUAL] >=5){
newCell = new Streamer(tNew, row, col);
}
//Stays a Casual user
else{
newCell = new Casual(tNew, row, col);
}
//Updates new town's grid
tNew.grid[row][col] = newCell;
//returns the new cell
return newCell;
}
}