step 35 adding piece names to globals.h and use them in displaying the board
added the following code to globals.h
Code: Select all
const char* PIECENAMES[16] = { " ","P ","K ","N "," ","B ","R ","Q ",//added it in step 35
" ","P*","K*","N*"," ","B*","R*","Q*" };
added the following code to extglobals.h
Code: Select all
extern const char* PIECENAMES[];//added this in step 35
added the following code to board.cpp in order to use printf in that file
Code: Select all
#include <iostream>//added in step 35
adding content to the display function in board.cpp and here is the relevant code.
Code: Select all
oid Board::display()//I added this function at step 34
{
//step 35 printing information about the board
int rank, file;
printf("\n");
for (rank = 8; rank >= 1; rank--)
{
printf(" +---+---+---+---+---+---+---+---+\n");
printf("%3d %s", rank, "|");
for (file = 1; file <= 8; file++)
printf(" %s%s", PIECENAMES[square[BOARDINDEX[file][rank]]], "|");
printf("\n");
}
}