This commit is contained in:
42
app/src/main/java/sudoku/structure/Block.java
Normal file
42
app/src/main/java/sudoku/structure/Block.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package sudoku.structure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Block {
|
||||
|
||||
private final List<Cell> cells;
|
||||
|
||||
public Block(List<Cell> cells) {
|
||||
this.cells = cells;
|
||||
}
|
||||
|
||||
public Block() {
|
||||
this.cells = new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<Cell> getCells() {
|
||||
return cells;
|
||||
}
|
||||
|
||||
void addCell(Cell newCell) {
|
||||
this.cells.add(newCell);
|
||||
}
|
||||
|
||||
public boolean containsSymbol(int symbolIndex) {
|
||||
for (Cell cell : getCells()) {
|
||||
if (cell.getSymbolIndex() == symbolIndex)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean containsCell(Cell cell) {
|
||||
for (Cell cellTmp : this.cells) {
|
||||
if (cellTmp.equals(cell)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user