⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 area.java

📁 用JAVA编写的数独游戏源代码,帮助你快速得到游戏的答案
💻 JAVA
字号:


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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -