area.java
来自「用JAVA编写的数独游戏源代码,帮助你快速得到游戏的答案」· Java 代码 · 共 73 行
JAVA
73 行
class Area {
AreaPosition position ;
Area (AreaPosition position ) {
this.position =position ;
}
Area (int datas_row_index , int datas_column_index ) {
this( AreaPosition.getAreaPosition(datas_row_index, datas_column_index ) ) ;
}
SingleData getCurrentSingleData() {
int[] data = new int[9] ;
for(int i=0;i<9;i++) {
AreaCellPosition cellPosition = new AreaCellPosition(i);
data[i] = getCell(cellPosition).getValue() ;
}
return new SingleData(data);
}
String getNumbersString() {
return getCurrentSingleData().getUsedNumbersString() ;
}
boolean hasElement(int number) {
return getCurrentSingleData().hasElement(number) ;
}
Cell getCell( AreaCellPosition cellPosition ) {
int row_index = position.getDatasRow_index(cellPosition ) ;
int column_index = position.getDatasColumn_index(cellPosition ) ;
return new Cell(row_index ,column_index ) ;
}
boolean[][] cannotSetValue(int number) {
boolean[][] result = new boolean[3][3] ;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++) {
AreaCellPosition cellPosition = new AreaCellPosition(i,j) ;
if ( getCell(cellPosition).hasValue()) result[i][j] = true ;
}
for(int i=0;i<3;i++) {
int row_index = position.getDatasRow_index(new AreaCellPosition(i,0)) ;
if ((new Row(row_index)).hasElement(number)) {
for(int j=0;j<3;j++) result[i][j] = true ;
}
}
for(int j=0;j<3;j++) {
int column_index = position.getDatasColumn_index( new AreaCellPosition(0,j)) ;
if ((new Column(column_index)).hasElement(number)) {
for(int i=0;i<3;i++) result[i][j] = true ;
}
}
return result ;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?