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

📄 squarefactory.java

📁 基于Java的五子棋的源代码
💻 JAVA
字号:
package net.sourceforge.gomoku;/** * @author <a href="mailto:anton.safonov@gmail.com">Anton Safonov</a> */public class SquareFactory {  private static final byte SMALL = 0;  private static final byte NORMAL = 1;  private static byte mode = SMALL;  public static final void init(int rows, int cols) {    if (rows < 16 && cols < 16) {      mode = SMALL;    } else {      mode = NORMAL;    }  }  public static final Square create() {    return create(-1, -1);  }  public static final Square create(int row, int col) {    switch (mode) {      case SMALL:        return new SmallSquare(row, col);      case NORMAL:      default:        return new NormalSquare(row, col);    }  }  public static void test() {    System.err.println("1: " + SquareFactory.create()); // default with -1, -1    System.err.println("2: " + SquareFactory.create(0, 0));    System.err.println("3: " + SquareFactory.create(5, 7));    System.err.println("4: " + SquareFactory.create(7, 5));    System.err.println("5: " + SquareFactory.create(14, 14));  }}

⌨️ 快捷键说明

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