-2
我有2個名爲CastlingCheck.java和Board.java的java文件。 CastlingCheck.java包含一個布爾方法(testCastling),我想在Board.java中調用它。將布爾方法從一個類傳遞到另一個類
CastlingCheck.java:
package chess;
public class CastlingCheck extends Board{
public boolean testCastling(int oldX, int oldY, int newX, int newY) {
int deltax = newX - oldX;
if (1st condition) {
**code here**
return true;
}
if (2nd condition) {
**code here**
return true;
}
if (3rd condition) {
**code here**
return true;
}
if (4thnd condition) {
**code here**
return true;
}
return false;
}
}
Board.java:
package chess;
...code...
public boolean testCastling(int oldx, int oldy, int newx, int newy) {
return true;
}
...code...
我這樣做對嗎?
CastlingCheck不是董事會。我知道。 CastlingCheck只是一個擁有我想在理事會課堂上要求的方法的課程。另外,是不是它應該是'boolean b = cc.textCastling(0,0,0,0)'?@StefaanNeyts – skg22 2015-04-03 07:55:21