-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCell.java
119 lines (100 loc) · 2.11 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**
* A class storing the properties of a cell.
*
* @author Jeremy Gonzales
* @version February 1, 2019
*/
public class Cell {
private char cellvalue;
private char concealedcellvalue;
private boolean containsmine;
private boolean border;
private boolean concealed;
private boolean played;
/**
* Constructs a cell with the default values.
*/
public Cell() {
cellvalue = '-';
concealedcellvalue = '-';
concealed = true;
border = false;
containsmine = false;
played = false;
}
/**
* Changes the cell into a border.
*/
public void setBorderState() {
border = true;
concealedcellvalue = ' ';
cellvalue = ' ';
}
/**
* Returns true or false if the cell is a border.
* @return the border state of a cell.
*/
public boolean getBorderState() {
return border;
}
/**
* Activates a mine in the cell.
*/
public void setMineState() {
cellvalue = 'M';
containsmine = true;
}
/**
* Returns true or false if the cell contains a mine.
* @return the mine state of the cell.
*/
public boolean getMineState() {
return containsmine;
}
/**
* Returns the value of the cell.
* @return the value of the cell.
*/
public char getCellvalue() {
return cellvalue;
}
/**
* Changes the cell value to the given value.
* @param a the new value of the cell.
*/
public void setCellvalue(char a) {
cellvalue = a;
}
/**
* Reveals the value of the cell.
*/
public void revealCellvalue() {
concealed = false;
}
/**
* Conceals the value of the cell.
*/
public void concealCellvalue() {
concealed = true;
}
/**
* Sets the played state of the cell to true.
*/
public void setPlayedState() {
played = true;
}
/**
* Returns true or false if the cell has been played.
* @return the played state of the cell.
*/
public boolean getPlayedState() {
return played;
}
@Override
public String toString() {
if (concealed == false) {
return String.valueOf(cellvalue);
}
return String.valueOf(concealedcellvalue);
}
}