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 阅读(563) 评论(0)  编辑  收藏 所属分类: Java学习笔记


只有注册用户登录后才能发表评论。


网站导航: