⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smallboard.java

📁 基于Java的五子棋的源代码
💻 JAVA
字号:
package net.sourceforge.gomoku;/** * @author <a href="mailto:anton.safonov@gmail.com">Anton Safonov</a> */public final class SmallBoard extends Board {  private final byte[] pieces;  private final byte rows;  private final byte cols;  SmallBoard(final int rows, final int cols) {    this.rows = (byte) rows;    this.cols = (byte) cols;    this.pieces = new byte[rows * cols];  }  int getRows() {    return this.rows;  }  int getCols() {    return this.cols;  }  Board copy() {    SmallBoard newBoard = new SmallBoard(getRows(), getCols());    System.arraycopy(this.pieces, 0, newBoard.pieces, 0, pieces.length);    return newBoard;  }  byte getPiece(final int row, final int col) {    try {      return pieces[toPosition(row, col)];    } catch (ArrayIndexOutOfBoundsException e) {      return NO_PIECE;    }  }  void setPiece(final int row, final int col, final byte piece) {    pieces[toPosition(row, col)] = piece;  }  void clear() {    for (int i = 0, max = pieces.length; i < max; ++i) {      pieces[i] = NO_PIECE;    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -