-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCell.java
76 lines (64 loc) · 1.39 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
public class Cell {
private int row;
private int column;
private boolean isBomb;
private int number;
private boolean isExplosed = false;
private boolean isGuess = false;
public Cell(int row, int column){
this.row = row;
this.column = column;
isBomb = false;
number = 0;
}
public void setRowAndColumn(int r, int c){
this.row = r;
this.column = c;
}
public void setBomb(boolean bomb){
this.isBomb = bomb;
number = -1;
}
public void incrementNumber(){
number++;
}
public boolean isBomb(){
return isBomb;
}
public boolean isBlank(){
return number == 0;
}
public boolean isExplosed() {
return isExplosed;
}
public int getRow(){
return row;
}
public int getColumn() {
return column;
}
public int getNumber(){
return number;
}
public boolean flip(){
isGuess = true;
return !isBomb;
}
public boolean isGuess(){
return isGuess;
}
public String getUndersideState(){
if(isBomb()){
return "*";
}else{
return Integer.toString(getNumber());
}
}
public String getSurfaceState(){
if(isGuess()){
return getUndersideState();
}else{
return "?";
}
}
}