-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