You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
779 B
Java
31 lines
779 B
Java
package reactivestreams;
|
|
|
|
public class SquareChecker extends DigitBlockChecker {
|
|
|
|
int squareRow;
|
|
int squareColumn;
|
|
|
|
public SquareChecker(int squareRow, int squareColumn) {
|
|
this.squareRow = squareRow;
|
|
this.squareColumn = squareColumn;
|
|
}
|
|
|
|
@Override
|
|
protected boolean currentDigitApplies(int currentRow, int currentColumn) {
|
|
return currentRowApplies(currentRow) && currentColumnApplies(currentColumn);
|
|
}
|
|
|
|
boolean currentRowApplies(int currentRow) {
|
|
int fromRow = squareRow * 3 - 2;
|
|
int toRow = fromRow + 2;
|
|
return currentRow >= fromRow && currentRow <= toRow;
|
|
}
|
|
|
|
boolean currentColumnApplies(int currentColumn) {
|
|
int fromColumn = squareColumn * 3 - 2;
|
|
int toColumn = fromColumn + 2;
|
|
return currentColumn >= fromColumn && currentColumn <= toColumn;
|
|
}
|
|
|
|
}
|