Java Developer

          Walking by the side of Java ,Working hard for my future……
          隨筆 - 4, 文章 - 45, 評論 - 5, 引用 - 0
          數據加載中……

          一個國際象棋棋盤的類

          public class GameBoard {

              
          private static final int WIDTH = 10;
              
          private static final int HEIGHT = 10;
              
          private static final int EMPTY = 0;

              
          private int board[][];

              
          public String myname;

              
          public GameBoard(String gamename) {
                  board 
          = new int[WIDTH][HEIGHT];
                  myname 
          = new String(gamename);
              }


              
          public final void cleanBoard(){
                  
          for(int i=0;i<WIDTH;i++)
                      
          for(int j=0;j<HEIGHT;j++)
                          board[i][j]
          =EMPTY;
              }

              
          public synchronized void setSquare(int x,int y,int value){
                  board[x][y]
          =value;
              }

              
          public synchronized boolean isEmpty(int x,int y){
                  
          if(board[x][y]==EMPTY)
                      
          return(true);
                  
          return(false);
              }


              
          private void jbInit() throws Exception {
              }

          }

          posted on 2005-07-20 09:50 Java Developer 閱讀(571) 評論(0)  編輯  收藏 所屬分類: Java學習筆記


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 昌图县| 万源市| 阿克| 龙南县| 新干县| 池州市| 聂拉木县| 内江市| 张北县| 商丘市| 丁青县| 乌兰察布市| 偃师市| 屏东市| 宁城县| 曲阜市| 三原县| 克拉玛依市| 龙海市| 诸城市| 沂水县| 阳江市| 许昌市| 安乡县| 老河口市| 慈溪市| 罗城| 齐河县| 墨玉县| 柳州市| 北宁市| 贡嘎县| 绥化市| 洛南县| 桦甸市| 高青县| 儋州市| 裕民县| 乌拉特中旗| 玉山县| 温宿县|