1. 团队名称、团队成员介绍
团队名称:WY
团队成员:
- 吴慧婷[组长] 201521123094 网络1514
- 姚佳希 201521123042 网络1512
2 项目git地址
3 项目git提交记录截图,老师将点击进去重点考核。
4 项目功能架构图与主要功能流程图
5 项目运行截图
开始
悔棋功能
重新开始
6 项目关键代码(不能太多)
- Chess.java
public Chess() {
board = new ChessBoard(45, 45, 9, 10);
record = board.record;
setTitle("中国象棋:默认红棋先行");
con = getContentPane();
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, board, record);
split.setDividerSize(5);
split.setDividerLocation(460);
con.add(split, BorderLayout.CENTER);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
setVisible(true);
setBounds(60, 20, 670, 540);
con.validate();
validate();
}
- ChessBoard.java
public void paintComponent(Graphics g)// 画棋盘
{
super.paintComponent(g);
for (int j = 1; j <= yaxislength; j++) {
g.drawLine(point[1][j].x, point[1][j].y, point[xaxislength][j].x, point[xaxislength][j].y);// 直线的起点坐标,终点坐标
}
for (int i = 1; i <= xaxislength; i++) {
if (i != 1 && i != xaxislength) {
g.drawLine(point[i][1].x, point[i][1].y, point[i][yaxislength - 5].x, point[i][yaxislength - 5].y);
g.drawLine(point[i][yaxislength - 4].x, point[i][yaxislength - 4].y, point[i][yaxislength].x,
point[i][yaxislength].y);// 竖直画线,多减一个格子总体向上平移一行
} else {
g.drawLine(point[i][1].x, point[i][1].y, point[i][yaxislength].x, point[i][yaxislength].y);
}
}
g.drawLine(point[4][1].x, point[4][1].y, point[6][3].x, point[6][3].y);
g.drawLine(point[6][1].x, point[6][1].y, point[4][3].x, point[4][3].y);
g.drawLine(point[4][8].x, point[4][8].y, point[6][yaxislength].x, point[6][yaxislength].y);
g.drawLine(point[4][yaxislength].x, point[4][yaxislength].y, point[6][8].x, point[6][8].y);
g.setFont(new Font("Serif", 6, 22));
g.drawString("楚 河 汉 界", point[2][5].x, point[2][6].y);
}
- ChessDo.java
public ChessDo(ChessBoard board, ChessPoint[][] point) {
this.board = board;
this.point = point;
scroll = new JScrollPane();
ChessManual = new LinkedList<MoveStep>();
EatPiece = new LinkedList<Object>();
buttonStart = new JButton("重新开始");
buttonStart.setFont(new Font("平体", Font.PLAIN, 20));
buttonUndo = new JButton("悔棋");
buttonUndo.setFont(new Font("平体", Font.PLAIN, 20));
buttonExit = new JButton("退出");
buttonExit.setFont(new Font("平体", Font.PLAIN, 20));
setLayout(new BorderLayout());
add(buttonStart, BorderLayout.CENTER);
add(buttonUndo, BorderLayout.NORTH);
add(buttonExit, BorderLayout.SOUTH);
buttonStart.addActionListener(this);
buttonUndo.addActionListener(this);
buttonExit.addActionListener(this);
}
public void recordChessManual(ChessPiece piece, int startI, int startJ, int endI, int endJ) {
//记录走棋内容
Point pStart = new Point(startI, startJ);
Point pEnd = new Point(endI, endJ);
MoveStep step = new MoveStep(pStart, pEnd);
ChessManual.add(step);
}
public void recordPieceEaten(Object object) {
EatPiece.add(object);
}
public LinkedList<MoveStep> getChessManual() {
return ChessManual;
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == buttonStart) {
......
}
}
7 尚待改进或者新的想法
- 尚待改进:
(1)让用户可以任意选择先手
(2)悔棋规定悔棋步数
(3)胜利时弹出胜利窗口
(4)界面的美化
(5)重新开始时不用弹出一个窗口而是消除原先的所有步骤。
8 团队成员任务分配,团队成员课程设计博客链接(以表格形式呈现),标明组长。
团队成员 | 个人博客链接 | 任务分配 |
---|---|---|
吴慧婷[组长] | 吴慧婷的博客 | Chess类,ChessDo类,ChessRule类 |
姚佳希 | 姚佳希的博客 | ChessBoard类,ChessPoint类,ChessPiece类 |