In main i have the following code:
Gameboard gameboard(8, 5);
HumanPlayer hp1('A'), hp2('B');
HumanPlayer players[2];
players[0] = hp1;
players[1] = hp2;
gameboard.show();
//int p = player
int input, p = 0;
while (cin >> input)
{
switch (input)
{
case 1:
if (players[p].setcoin(gameboard, input))
.
.
.
In class HumanPlayer i call the function of gameboard and return it
bool HumanPlayer::setcoin(Gameboard g, int row)
{
return g.setstone(name, row);
}
In class Gameboard i set the coin (if it is full i return false)
bool Gameboard::setstone(char player, int row)
{
for (int y = height; y >= 0; y--)
{
//row-1 da das array bei 0 beginnt
if (elements[y][row-1] == '.')
{
elements[y][row-1] = player;
return true;
}
}
return false;
}