-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCell.java
More file actions
62 lines (56 loc) · 1.31 KB
/
Copy pathCell.java
File metadata and controls
62 lines (56 loc) · 1.31 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.util.List;
import java.util.ArrayList;
public class Cell {
private int row;
private int column;
private boolean has_mine=false;
private boolean open=false;
private int mine_count = 0;
private List<Cell> neighbors = new ArrayList<Cell>();
public Cell(int column,int row){
this.row =row;
this.column = column;
}
public void addNeighbor(Cell cell){
if(neighbors.contains(cell))
return;
neighbors.add(cell);
}
public void addMine(){
has_mine=true;
for(int i=0;i<neighbors.size();i++) {
Cell neighbor = neighbors.get(i);
neighbor.mine_count +=1;
}
}
public void open(){
this.open=true;
}
public boolean is_Open(){
if(this.open==true){
return true;
}
return false;
}
public String toString() {
if (!this.open) {
return "-";
} else if (this.has_mine) {
return "*";
} else {
return Integer.toString(this.mine_count);
}
}
public int getRow(){
return row;
}
public int getColumn(){
return column;
}
public List getNeighbours(){
return neighbors;
}
public boolean has_mine() {
return has_mine;
}
}