这是我的代码:我希望让getBoard()方法在弹出最新的主板后返回堆栈的主板。有什么我需要改变的吗?
public void undo(){
redo.push(getBoard());
state.pop();
board = ((int[][]) state.peek());
}
public void redo(){
state.push(getBoard());
redo.pop();
board = ((int[][])redo.peek());
}
public void undoAction(View view){
twentyFortyEight.undo();
customGrid.updateGrid(twentyFortyEight.getBoard());
scoreBox.setText((Integer.toString(twentyFortyEight.getScore())));
}
public void redoAction(View view){
twentyFortyEight.redo();
customGrid.updateGrid(twentyFortyEight.getBoard());
}
答案 0 :(得分:0)
要做getBoard()方法,你需要创建这个方法,然后在那里做一些事情或从已经存在的其他方法调用
int[][] board;
public int[][] getBoard(){
int[][] b;
//...
return b;
}
board = getBoard();