-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