-2
我对使用我正在编写的代码时遇到的问题有疑问。我需要创建一个数独棋盘检查器。目标是通过使用5个特定的方法来扩展Sudoku类(使CheckableSudoku类),我必须使用public boolean checkAll()来检查所有的方法,如果它们通过则返回true。继承人我的代码!很抱歉,如果我解释说这也太容易混淆:/Sudoku Checker Java
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());
}
}
什么,具体而言,是你的问题? – Keppil 2013-04-22 21:15:01
而你的问题是? – 2013-04-22 21:51:08