1: 棋子横向位置 int chessman_X
2: 棋子纵向位置 int chessman_Y
3: 落子总个数 black_chessman_count
4: 身份标识 int black_chessplayer
方法:
1: 提交棋子 submit_chessman(int , int)
白方对象:
属性:
1:棋子横向位置 int chessman_X
2:棋子纵向位置 int chessman_Y
3:落子总个数 white_chessman_count
4:身份标识 int white_chessplayer
方法:
1: 提交棋子 submit_chessman(int ,int )
三个头文件对应三个对象:
黑棋选手:
#include<iostream>
using namespace std;
class black
{
int chessman_X; //横向位置
int chessman_Y; //纵向位置
int black_chessman_count ; //落子总数
int black_chessmanplayer ;
public:
black()
{
black_chessman_count=0;
black_chessmanplayer=-1;
}
bool submit_chessman(int chessman_X , int chessman_Y )
{
if(chessman_X>15 || chessman_X<1 || chessman_Y>15 ||chessman_Y<1)
{
return false;
}
else
{
this->chessman_X = chessman_X;
this->chessman_Y = chessman_Y;
black_chessman_count++;
return true;
}
}
int getIdentity()
{
return black_chessmanplayer;
}
int getChessman_X()
{
return chessman_X-1; //这里设置减一是因为画图从0位置开始
}
int getChessman_Y()
{
return chessman_Y-1;
}
int getChessmanCount()
{
return black_chessman_count ;
}
};
白棋选手:
#include<iostream>
using namespace std;
class white
{
int chessman_X; //横向位置
int chessman_Y; //纵向位置
int white_chessman_count; //落子总数
int white_chessmanplayer;
public:
white()
{
white_chessman_count=0;
white_chessmanplayer=1;
}
bool submit_chessman(int chessman_X , int chessman_Y )
{
if(chessman_X>15 || chessman_X<1 || chessman_Y>15 || chessman_Y<1)
{
return false;
}
else
{
this->chessman_X = chessman_X;
this->chessman_Y = chessman_Y;
white_chessman_count++;
return true;
}
}
int getIdentity()
{
return white_chessmanplayer;
}
int getChessman_X()
{
return chessman_X-1;
}
int getChessman_Y()
{
return chessman_Y-1;
}
int getChessmanCount()
{
return white_chessman_count ;
}
};










