資源簡介
本中國象棋實現網絡功能 在這上面加上了一很實用功能
界面美觀

代碼片段和文件信息
package?com.t38.chess;
import?com.t38.client.InitMap;
/**
?*?兵與卒的類
?*?
?*?@author?楊釗和羅歡所作
?*?
?*/
public?class?Bing?extends?Chess?{
/**
?*?吃棋方法
?*?
?*?@param?col
?*????????????是列
?*?@param?row
?*????????????是行
?*?@param?getPlayer
?*????????????1?是紅,2?是黑
?*?@return?走棋是否成功返回(true/false)
?*?
?*/
public?boolean?cq(int?noa?int?nob)?{
//?要走的棋子位置
Location?meLocation?=?InitMap.chesses[noa].getLocation();
//?被吃的棋子位置
Location?youLocation?=?InitMap.chesses[nob].getLocation();
//?紅方
if?(InitMap.chesses[noa].getPlayer()?==?1)?{
//?豎著吃棋
if?(meLocation.getRow()?-?youLocation.getRow()?==?-1
&&?meLocation.getCol()?-?youLocation.getCol()?==?0)?{
return?true;
}
//?橫著吃棋
if?(meLocation.getRow()?>?4
&&?Math.abs(meLocation.getCol()?-?youLocation.getCol())?==?1
&&?meLocation.getRow()?-?youLocation.getRow()?==?0)?{
return?true;
}
}
//?黑方
if?(InitMap.chesses[noa].getPlayer()?==?2)?{
//?豎著吃棋
if?(meLocation.getRow()?-?youLocation.getRow()?==?1
&&?meLocation.getCol()?-?youLocation.getCol()?==?0)?{
return?true;
}
//?橫著吃棋
if?(meLocation.getRow()?5
&&?Math.abs(meLocation.getCol()?-?youLocation.getCol())?==?1
&&?meLocation.getRow()?-?youLocation.getRow()?==?0)?{
return?true;
}
}
return?false;
}
/**
?*?走棋方法
?*?
?*?@param?col
?*????????????是列
?*?@param?row
?*????????????是行
?*?@param?no
?*????????????序列號,第幾粒子!
?*?@param?getPlayer
?*????????????1?是紅,2?是黑
?*?@return?走棋是否成功返回(true/false)
?*?
?*/
public?boolean?zq(int?no?int?row?int?col)?{
//?棋子原來的位置
Location?old?=?InitMap.chesses[no].getLocation();
//?紅兵
if?(no?==?11?||?no?==?12?||?no?==?13?||?no?==?14?||?no?==?15)?{
if?(row?>?4)?{
//?右走1(橫走)
if?(old.getCol()?-?col?==?-1?&&?old.getRow()?-?row?==?0)?{
//?是否有障礙物
//?遍歷32顆棋子看是否有棋子在障礙物位置上
for?(int?i?=?0;?i?32;?i++)?{
//?其他棋子位置
Location?qt?=?InitMap.chesses[i].getLocation();
if?(old.getCol()?-?qt.getCol()?==?-1
&&?old.getRow()?-?qt.getRow()?==?0)?{
return?false;
}
}
return?true;
}
//?左走1(橫走)
if?(old.getCol()?-?col?==?1?&&?old.getRow()?-?row?==?0)?{
//?是否有障礙物
//?遍歷32顆棋子看是否有棋子在障礙物位置上
for?(int?i?=?0;?i?32;?i++)?{
//?其他棋子位置
Location?qt?=?InitMap.chesses[i].getLocation();
if?(old.getCol()?-?qt.getCol()?==?1
&&?old.getRow()?-?qt.getRow()?==?0)?{
return?false;
}
}
return?true;
}
}
//?下走2(豎走)
if?(old.getCol()?-?col?==?0?&&?old.getRow()?-?row?==?-1)?{
//?是否有障礙物
//?遍歷32顆棋子看是否有棋子在障礙物位置上
for?(int?i?=?0;?i?32;?i++)?{
//?其他棋子位置
Location?qt?=?InitMap.chesses[i].getLocation();
if?(old.getCol()?-?qt.getCol()?==?0
&&?old.getRow()?-?qt.getRow()?==?-1)?{
return?false;
}
}
return?true;
}
}
if?(no?==?16
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2569??2011-01-22?08:15??五人組版ycp\bin\image\紅相紅.gif
?????文件???????2352??2011-01-22?08:15??五人組版ycp\bin\image\紅車.gif
?????文件???????2461??2011-01-22?08:15??五人組版ycp\bin\image\紅車1.jpg
?????文件???????2561??2011-01-22?08:15??五人組版ycp\bin\image\紅車紅.gif
?????文件???????2404??2011-01-22?08:15??五人組版ycp\bin\image\紅馬.gif
?????文件???????2396??2011-01-22?08:15??五人組版ycp\bin\image\紅馬1.jpg
?????文件???????2583??2011-01-22?08:15??五人組版ycp\bin\image\紅馬紅.gif
?????文件???????2465??2011-01-22?08:15??五人組版ycp\bin\image\黑仕.gif
?????文件???????2453??2011-01-22?08:15??五人組版ycp\bin\image\黑仕1.jpg
?????文件???????2549??2011-01-22?08:15??五人組版ycp\bin\image\黑仕黑.gif
?????文件???????2470??2011-01-22?08:15??五人組版ycp\bin\image\黑卒.gif
?????文件???????2441??2011-01-22?08:15??五人組版ycp\bin\image\黑卒1.jpg
?????文件???????2487??2011-01-22?08:15??五人組版ycp\bin\image\黑卒黑.gif
?????文件???????2466??2011-01-22?08:15??五人組版ycp\bin\image\黑將.gif
?????文件???????2565??2011-01-22?08:15??五人組版ycp\bin\image\黑將1.jpg
?????文件???????2693??2011-01-22?08:15??五人組版ycp\bin\image\黑將黑.gif
?????文件???????2582??2011-01-22?08:15??五人組版ycp\bin\image\黑炮.gif
?????文件???????2506??2011-01-22?08:15??五人組版ycp\bin\image\黑炮1.jpg
?????文件???????2628??2011-01-22?08:15??五人組版ycp\bin\image\黑炮黑.gif
?????文件???????2587??2011-01-22?08:15??五人組版ycp\bin\image\黑象.gif
?????文件???????2510??2011-01-22?08:15??五人組版ycp\bin\image\黑象1.jpg
?????文件???????2627??2011-01-22?08:15??五人組版ycp\bin\image\黑象黑.gif
?????文件???????2542??2011-01-22?08:15??五人組版ycp\bin\image\黑車.gif
?????文件???????2486??2011-01-22?08:15??五人組版ycp\bin\image\黑車1.jpg
?????文件???????2614??2011-01-22?08:15??五人組版ycp\bin\image\黑車黑.gif
?????文件???????2502??2011-01-22?08:15??五人組版ycp\bin\image\黑馬.gif
?????文件???????2414??2011-01-22?08:15??五人組版ycp\bin\image\黑馬1.jpg
?????文件???????2567??2011-01-22?08:15??五人組版ycp\bin\image\黑馬黑.gif
?????文件????????391??2011-01-22?08:47??五人組版ycp\bin\net\ChessInfo.class
?????文件??????15151??2011-01-22?08:15??五人組版ycp\music\chess.wav
............此處省略162個文件信息
- 上一篇:生產者 消費者 進程 可視化 java
- 下一篇:JAVA程序設計教程課后習題答案
評論
共有 條評論