-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCell.java
55 lines (49 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
public class Cell {
public int numRows, numCols, r, c, b;
public Cell below, right, block;
public Integer value;
public List<Integer> possibleValues;
public String toString() {
if (value == null) {
String res = " ";
for (int i = 0; i < String.valueOf(numRows * numCols).length(); i++) {
res += "-";
}
res += " ";
return res;
}
return " " + String.format("%" + String.valueOf(numRows * numCols).length() + "d", value).replace(" ", "0")
+ " ";
}
/*
* Don't change anything above this line
*/
public Cell(int nR, int nC, String inp) {
this.numRows = nR;
this.numCols = nC;
if(inp == "-") {
this.value = null;
this.possibleValues = new List();
for(Integer counter = 1; counter <= this.numCols * this.numRows; counter++) {
this.possibleValues.append(counter);
}
}
else {
this.setVal(Integer.parseInt(inp));
}
}
public void removeVal(int val) {
if(this.possibleValues != null) {
boolean tempRemove = this.possibleValues.remove(val);
tempRemove = !(!tempRemove);
return;
}
else {
return;
}
}
public void setVal(int val) {
this.value = val;
this.possibleValues = null;
}
}