この課題の締め切りに間に合いませんでしたが、このプロジェクトで何をしているのか理解できずにいまだに悩まされています。4 つのメソッドを追加する必要がある数独ソリューション チェッカーのパート 2
public boolean checkAndPrintReport( ) {*/return true;}
すべてをチェックし、失敗した行または列ごとに行を出力する必要があります。他は
public boolean isGoodRow( int yRowParam ) {return true;}
public boolean isGoodColumn( int xColParam ) {return true;}
public boolean isGoodBlock(int xBlockP, int yBlockP) {return true;}
最後に、私の checkAll() メソッドには、上記の 3 つをそれぞれ 9 回呼び出す 3 つの入れ子になったループがあるはずです。
ここでソリューションチェッカーをすでにコーディングしていると思っていたので、この部分に何が必要なのかわかりません
public int timesRowHas( int yParam, int number ) {
int nTimesHas = 0;
for( int x = 0; x < 9; x++ )
if( this.getCell(x, yParam) == number )
nTimesHas = nTimesHas + 1;
return( nTimesHas );
}
public int timesColHas( int xParam, int number ) {
int nTimesHas = 0;
for( int y = 0; y < 9; y++ )
if( this.getCell(xParam, y) == number )
nTimesHas = nTimesHas + 1;
return( nTimesHas );
}
public int timesBlockHas( int xBlockParam, int yBlockParam, int number ) {
if( xBlockParam < 0 || xBlockParam > 2 || yBlockParam < 0 || yBlockParam > 2 )
throw new IllegalArgumentException("Bad xBlockParam or bad yBlockParam or both..");
int nTimesHas = 0;
for (int x=0; x<3; x++)
for (int y=0; y<3;y++)
nTimesHas = nTimesHas +getCell(xBlockParam+x, yBlockParam+y);
return(nTimesHas);
}