我是 Java 新手,如果有人能提供以下帮助,我将不胜感激。我正在尝试为我的棋盘制作记分员。此刻,分数将每次归零。我如何能够保存以前的分数并在每一步中添加它?谢谢!
public static int scoreKeeper(Chessmen[][] chessboard, int X, int Y, int X1, int Y1, int currentNumber, int totalNumber){
AbstractPiece knight = new Knight();
AbstractPiece bishop = new Bishop();
AbstractPiece pawn = new Pawn();
AbstractPiece king = new King();
AbstractPiece queen = new Queen();
AbstractPiece rook = new Rook();
if ((chessboard[Y][X] == Chessmen.WHITE_KNIGHT) ||
(chessboard[Y][X] == Chessmen.BLACK_KNIGHT)){
currentNumber = currentNumber+totalNumber+knight.relativeValue();
return currentNumber;
}else return totalNumber;
}