Java:更改播放器

时间:2018-10-26 14:55:26

标签: java

我不知道如何编写转换回合来更改播放器的玩家

编辑:从布尔播放器开始或在...

import java.util.*;
public class Assignment {
static Scanner sc = new Scanner(System.in);
static int height = 6, width = 6, blank = 0;          //do checkerboard
static int white = 1, black = 2;                      //do player chess
static int[][] board;
    public static void main(String[] args) {
    board = new int[height][width];

    board[width / 2-1][height / 2-1] = board[width / 2][height / 2] = 1;
    board[width / 2-1][height / 2] = board[width / 2][height / 2-1] = 2;

    printHead();
    printboard();
    input();
}
    public static void input() {

}

}

1 个答案:

答案 0 :(得分:0)

要确定哪个玩家在玩,可以使用boolean之类的boolean player1变量。只要player1为真,就轮到第一个玩家了。如果为假,则是第二个玩家回合。播放器完成后,您可以在您的方法中添加行

player1 = !player1;

要切换player1的值,以便在下一回合您的程序将知道播放器已切换。