public void drawPieces(Graphics g) { g.setColor(Color.red); for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++) { Piece piece = chessBoard.getPiece(i, j); if (piece != null) g.drawString(piece.toString(), i * 50, j * 50 + 10); } }
public String toString() { if (piece == null) { StringBuffer buf = new StringBuffer(); buf.append(Board.getFileChar(file)); buf.append(rank); return buf.toString(); } else return piece.toString(); }
public void printGame() { for (Piece[] row : game) { for (Piece piece : row) { if (piece == null) { System.out.print(" NULL "); } else { System.out.print(piece.toString() + " "); } } System.out.println(); } }