【发布时间】:2013-12-03 05:54:58
【问题描述】:
我现在正在使用 Java 开发数独解决方案检查器,它被分成两部分。第二部分希望在代码中添加五个新的“特定方法”,它们是对行、列、块的布尔检查,然后在循环中返回它们是否为真或假。 checkAndPrintReport 还应该为每行检查失败、列检查失败和 区块检查失败。这就是我目前的情况。
public boolean checkAndPrintReport( )
{
return false;
}
public boolean isGoodRow( int yRowParam )
{
int sum = 0;
for ( int x = 0; x <9; x++)
{
sum = sum + getCell (x,yRowParam);
}
return( true );
}
public boolean isGoodColumn( int xColParam )
{
int sum = 0;
for (int y = 0; y < 9 ;y++)
{
sum = sum + getCell (xColParam, y);
}
return( true );
}
public boolean isGoodBlock(int xBlockP, int yBlockP)
{
int sum = 0;
for (int x=0; x<3; x++)
{
for (int y=0; y<3;y++)
{
sum = sum + getCell (xBlockP+x, yBlockP+y);
}
}
return( true );
}
public boolean checkAll()
{
}
我认为现在让我感到困惑的主要部分是这与我已经创建的检查这些东西的代码有什么不同......所以我有点困惑我被问到了什么。
【问题讨论】:
-
先让现有代码工作。所有这些函数总是返回 true,因为总和值没有经过测试。