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

📄 chesstable.java~13~

📁 手机端游戏开发程序
💻 JAVA~13~
字号:
package chess;

import java.util.*;

public class ChessTable {
  //static int N=10;
  private Vector Left; //=new Vector(N);
  private Vector Right; //=new Vector(N);
  public ChessTable(int N) { //申请N张桌子
    String s = "@@@@@@@@@@@";
    Left = new Vector();
    Right = new Vector();
    for (int i = 0; i < N - 1; i++) {
      Left.add(s);
      Right.add(s);
    }
  }
public String getName(int i,int lr){
  if(lr==0){//左边
    return (String) Left.elementAt(i-1);
  }
  else if(lr==1){//右边
    return (String) Right.elementAt(i-1);
  }
  return "#";
}
  public boolean sitLeft(int i, String uname) { //坐在i号桌子的左侧
    if (Left.elementAt(i - 1).equals("#")) {
      Left.add(i - 1, uname);
      return true;
    }
    else {
      return false; //已经有人
    }
  }

  public boolean sitRight(int i, String uname) { //坐在i号桌子的左侧
    if (Right.elementAt(i - 1).equals("#")) {
      Right.add(i - 1, uname);
      return true;
    }
    else {
      return false; //已经有人
    }
  }

  public boolean isFull(int i) { //查看第i号桌子是否已经做满
    i--;
    if (! (Right.elementAt(i).equals("#")) & ! (Left.elementAt(i).equals("#"))) {
      return true;
    }
    else {
      return false;
    }
  }

}

⌨️ 快捷键说明

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