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

📄 cram.java

📁 java版的数据结构的完全代码 免费提供了 学习数据结构的请下载
💻 JAVA
字号:
// Introduced in Chapter 3/** The game of Cram. */public class Cram extends Domineering {  /** No special initialization is required. */  public Cram() {    super();  }    /** Play until someone wins. */  public void play() {    int player = 1;    while (true) {      System.out.println("\n" + this);      System.out.println("Player " + player + " to play");      if (!(hasLegalMoveFor(HORIZONTAL)            || hasLegalMoveFor(VERTICAL))) {        System.out.println("No legal moves -- you lose!");        return;      }      System.out.print("Row: ");      int row = INPUT.nextInt();      System.out.print("Column: ");      int column = INPUT.nextInt();      INPUT.nextLine();         // To clear out input      System.out.print("Play horizontally (y/n)? ");      boolean direction;      if (INPUT.nextLine().charAt(0) == 'y') {        direction = HORIZONTAL;      } else {        direction = VERTICAL;      }      playAt(row, column, direction);      player = 3 - player;    }  }  /** Create and play the game. */  public static void main(String[] args) {    System.out.println("Welcome to Cram.");    Cram game = new Cram();    game.play();  }}

⌨️ 快捷键说明

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