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() {


}

}


BIG阳
浏览 141回答 1
1回答

杨__羊羊

要确定哪个玩家在玩,您可以使用一个boolean变量,例如boolean player1. 每当player1为真时,就轮到第一个玩家了。当它为假时,是第二个玩家轮到。在播放器完成后的方法中,您可以添加该行player1 = !player1;切换 的值,player1以便在下一轮您的程序将知道播放器已切换。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java