前言
相对于推箱子游戏,五子棋游戏加入了判断方法,即是否五子连棋。
一、Java二维数组
通过对Java二维数组的创建、修改、打印和字符判断实现五子棋游戏。
二、实现方法
1.引入库
代码如下:
import java.util.Scanner;
2.创建棋盘
创建长度11*11棋盘,代码如下:
String[][] arr = new String[11][11];
arr[0] = new String[] {
" 0"," 1"," 2"," 3"," 4"," 5"," 6"," 7"," 8"," 9"," 10"};
arr[1]=new String []{
" 1"," -"," -"," -"," -"," -"," -"," -"," -"," -"," -"};
arr[2] =new String[]{
" 2"," -"," -"," -"," -"," -"," -"," -"," -"," -"," -"};
arr[3] =new String[]{
" 3"," -"," -"," -"," -"," -"," -"," -"," -"," -"," -"};
arr[4] =new String[]{
" 4"," -"," -"," -"," -"," -"," -"," -"," -"," -"," -"};
arr[5] =new String[]{
" 5"," -"," -"," -"," -"," -"," -"," -"," -"," -"," -"};
arr[6] =new String[