1.java?象棋象棋相册类源码???Դ??
java????Դ??
int[][] loaction=new int[][9];
左帅:loaction[0][4];
X X X
X X
X X X
-----
[0][3] [1][3] [2][3]
[0][4] [1][4] [2][4]
[0][5] [1][5] [2][5]
即:x>=0 && x<=2 && y>=3 && y<=5
------------------------------
右将:loaction[9][4];
X X X
X X
X X X
-----
[7][3] [8][3] [9][3]
[7][4] [8][4] [9][4]
[7][5] [8][5] [9][5]
---------------------------
public int go(int x,int y,int path,int len){
if(loaction[x][y]==1) { //是帅
if(path==1){ //向左
if(x<=0) return -1;//返回-1代表走发错误
else { loaction[x-1][y]=1;loaction[x][y]=-1;}//将左一个格子标记为帅
}
else if(path==2){ //向上
...
}
else if(path==3){ //向右
...
}
else if(path==4){ //向下
...
}//else path
}//if key
else if(loaction[x][x]==2){ //2代表将
....
}//if key
}
车就差不多了