В моем классе не вызываются поля через точку.В чем проблема? Кто подскажет как создать правильно этот класс?
Код:
#include<iostream>
using namespace std;
class Game
{
public:
Player player;
Computer computer;
int x,y,x1,y1,x2,y2;
bool PlayerWins;
bool ComputerWins;
public:
Game();
~Game();
void SetShips();
void RunGame();
};
Game::Game()
{
PlayerWins=false;
ComputerWins=false;
}
Game::~Game(){}
void Game::SetShips()
{
player.PrintFields();
player.SetFlotShip(4);
computer.SetFlotShip(4);
for(int i=0;i<2;i++)
{
player.PrintFields();
player.SetFlotShip(3);
computer.SetFlotShip(3);
}
for(int i=0;i<3;i++)
{
player.PrintFields();
player.SetFlotShip(2);
computer.SetFlotShip(2);
}
for(int i=0;i<2;i++)
{
player.PrintFields();
player.SetFlotShip(1);
computer.SetFlotShip(1);
}
void Game::RunGame()
{
while(true)
{
while(true)
{
player.PrintFields();
player.GetAttackCoordinates(x,y);
if(player.GetSecondFieldElement(x,y)=='x'||player.GetSecondFieldElement(x,y)=='0')
cout<<" It's no use to shoot !\n";
getch();
}
else
{
if(computer.GetFirstFieldElement(x,y)=" ")
{
player.SetSecondFieldElemet(x,y,'0')
player.PrintFields();
break;
}
else
{
player.SetSecondFieldElement(x,y,'x');
computer.SetFirstFieldElement(x,y,'x');
if(computer.ShipTest(x,y)
{
computer.GetDeleteShipCoordinates(x,y,x1,y1,x2,y2);
player.DeleteOpponentShip(x1,y1,x2,y2);
}
computer.DeleteFlotLife();
if(computer.FlotLifeTest()//если эскадра разгромлена
{
PlayerWins=true;
player.PrintFields();
break;
}
}
}
if(PlayerWins==true)
{
player.PrintFields();
cout<<" Player wins !\n";
break;
}
while(true)
{
computer.GetAttackCoordinates(x,y);
if(computer.GetSecondFieldElement(x,y)=='x'||computer.GetSecondFieldElement(x,y)=='0')
continue;
else
{
if(player.GetFirstFieldElement(x,y)==' ')
{
computer.SetSecondFieldElement(x,y,'0');
player.SetFirstFieldElement(x,y,'0');
break;
}
else
{
player.SetFirstFieldElement(x,y,'x');
computer.SetSecondFieldElement(x,y,'x');
player.PrintFields();
getch();
if(player.ShipTest))
{
player.GetDeleteShipCoordinates(x,y,x1,y1.x2,y2);
player.GetDeletePlayerShip(x1,y1,x2,y2);
player.PrintFields();
getch();
computer.DeleteOpponentShip(x1,y1,x2,y2)
}
player.DeleteFlotLife();
if(player.FlotLifeTest())
{
ComputerWins=true;
player.PrintFields();
break;
}
}
}
}
if(ComputerWins==true)
{
player.PrintFields();
cout<<" Computer wins !\n";
getch();
break;
}
void main()
{
Game one;
one.SetShips();
one.RunGame();
return 0;
}