-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cell.java
83 lines (65 loc) · 1.49 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
public class Cell {
boolean alive;
boolean calculatedValue;
boolean calculated;
boolean updated;
int level;
// public ReentrantLock lock = new ReentrantLock();
public Cell(boolean status) {
this.level = 0;
alive = status;
calculated = false;
updated = false;
calculatedValue = false;
}
public synchronized int getLevel() {
return this.level;
}
public synchronized void setLevel() {
this.level++;
}
public synchronized boolean getStatus() {
return alive;
}
public synchronized void setStatus(boolean input) {
alive = input;
}
public synchronized void setCalculatedValue(boolean input) {
// this.calculated = true;
this.calculatedValue = input;
}
public synchronized boolean getCalculatedValue() {
return calculatedValue;
}
public synchronized void setCalculated(boolean input) {
calculated = input;
}
public synchronized boolean getCalculated() {
return calculated;
}
public synchronized void setUpdated(boolean input) {
updated = input;
}
public synchronized boolean getUpdated() {
return updated;
}
public void update(boolean update) {
alive = update;
level++;
}
public int checkIteration() {
return level;
}
public boolean checkStatus() {
return alive;
}
public synchronized void printCell() {
if (alive) {
System.out.print("x");
} else{
System.out.print(".");
}
}
}