Java课程设计html
开始
java
悔棋功能
git
从新开始
网络
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(); }
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); }
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) { ...... } }
(1)让用户能够任意选择先手 (2)悔棋规定悔棋步数 (3)胜利时弹出胜利窗口 (4)界面的美化 (5)从新开始时不用弹出一个窗口而是消除原先的全部步骤。
团队成员 | 我的博客连接 | 任务分配 |
---|---|---|
吴慧婷[组长] | 吴慧婷的博客 | Chess类,ChessDo类,ChessRule类 |
姚佳希 | 姚佳希的博客 | ChessBoard类,ChessPoint类,ChessPiece类 |