書いているコードで発生している問題について質問があります。数独ボード チェッカーを作成する必要があります。目標は、5 つの特定のメソッドを使用して Sudoku クラスを拡張する (CheckableSudoku クラスを作成する) ことです。 public boolean checkAll( ) を使用してすべてのメソッドをチェックし、合格した場合は true を返します。これが私のコードです!私がこれをあまりにも混乱させて説明した場合は申し訳ありません:/
import java.util.Scanner;
public class CheckableSudoku extends Sudoku
{
public int getCell(int xColumn, int yRow)
{
return this.board[xColumn][yRow];
}
public boolean checkRow (int yCoord)
{
int sum = 0;
for ( int x = 0; x <9; x++)
{
sum = sum + getCell (x,yCoord);
}
return( true );
}
public boolean checkColumn (int xCoord)
{
int sum = 0;
for (int y = 0; y < 9 ;y++)
{
sum = sum + getCell (xCoord, y);
}
return( true );
}
public boolean checkBlock (int col0to2, int row0to2)
{
int sum = 0;
for (int x=0; x<3; x++)
{
for (int y=0; y<3;y++)
{
sum = sum + getCell (col0to2+x, row0to2+y);
}
}
return( true);
}
public boolean checkAll()
{
// this is the method that checks all the other methods above
return true;
}
public static void main(String[] a)
{
CheckableSudoku me = new CheckableSudoku();
Scanner sc = new Scanner(System.in);
me.read(sc);
System.out.print(me);
System.out.println(me.checkAll());
}
}