Hi to everyone can somebody find me the header file in net for this source code
Thanks
#include "MouseAndCatGame.h"
MouseAndCatGame::MouseAndCatGame
(InterFace* pui, Player* pplayer)
:underground_(), p_ui(pui),
p_player(pplayer), cheatModeOn(false)
{
//prepare game
//mouse state already set up in
//its constructor
//set up cat
cat_.SpotMouse(&mouse_);
positionAtRandom();
}
const RandomNumberGenerator
MouseAndCatGame::rng;
void MouseAndCatGame::run()
{
p_ui-
>drawGridOnScreen(prepareGrid());
key_ = p_ui-
>getKeyPressFromUser();
const int KEY_C = 67;
while (!hasEnded (key_))
{
if(isArrowKeyCode(key_))
{
mouse_.scamper(key_);
if (!cheatModeOn)
cat_.chaseMouse();
p_ui-
>drawGridOnScreen(prepareGrid());
applyRules();
}
else if (KEY_ == KEY_C)
{
//toggle the cheat mode
cheatModeOn = !cheatModeOn;
p_ui-
>drawGridOnScreen(prepareGrid());
}
key_ = p_ui-
>getKeyPressFromUser();
}
p_ui-
>showResultsOnScreen(prepareEndMessage());
}
string MouseAndCatGame::prepareGrid()
const
{
//prepare string that holds the grid
//information
ostringstream os;
for(int row(1);row<=SIZE;++row)//for each row (vertically)
{
for(int col(1);col<=SIZE;++col)//for each column (horizontally)
{
if((row==cat_.y_)&&(col==cat_.x_))
os<<cat_.getSymbol();//show cat
else if((row==mouse_.getY())&&(col==mouse_.getX()))
mouse_.getSymbol();//showmouse
else if
((nut_.hasBeenCollected()== false)&&(row==nut_.getY())&&(col==nut_.getX()))
os<<nut_.getSymbol();
else
{
if(underground_.checkForHole(col,row))
os<<underground_.getHoleSymbol()
else
os<<FREECELL;//show freegrid cell
}
}//end of col-loop
os<<endl;
}//end of row-loop
os<<endl<<p_player->getName()<<" Score: "<<p_player->getScoreAmount();
if(nut_.hasBeenCollected())
os<<collectedNutMessage();
if(cheatModeOn)
os<<"\nCheat Mode Activated!";
return os.str();
}//end prepareGrid
bool
MouseAndCatGame::isArrowKeyCode(const int keycode)
const
{
return (keycode==LEFT)||(keycode==RIGHT)||(keycode==UP)||(keycode==DOWN);
}
void MouseAndCatGame::applyRules()
{
if(cat_.hasCaughtMouse())
{
mouse_.die();
p_player->updateScoreAmount(-1);
}
else if(house_.hasNut(&nut_)&&mouse_.hasReechedAHole(&underground_))
{
mouse_.escapeIntoHole();
p_player->updateScoreAmount(1);
}
}
bool MouseAndCatGame::hasEnded(char key)
const
{
return((key==QUIT)||(!mouse_.isAlive())||(mouse_.hasEscaped()))
}
string
MouseAndCatGame::collectedNutMessage()
const
{
return "\nTHE NUT HAS BEEN COLLECTED";
}
string
MouseAndCatGame::prepareEndMessage()
const
{
ostringstream os;
if(mouse_.hasEscaped())
os<<"\n\nEND OF GAME: THE MOUSE ESCAPED UNDERGROUND!";
else if(!mouse_.isAlive())
os<<"\n\nEND OF GAME: THE PLAYER ENDED THE GAME!";
return os.str;
}
void MouseAndCatGame::positionAtRandom()
{
int x=0;
int y=0;
do
{
x=rng_.getRamdomValue(SITE);
y=rng_.getRandomValue(SITE);
nut_.SetPosition(x,y);
}
while
(underground_.checkForHole(x,y));
do
{
x=rng_.getRandomValue(SIZE);
y=rng_.getRandomValue(SIZE);
mouse_.setPosition(x,y);
}
while
((underground_.checkForHole(x,y))||(nut_.isAtPosition(x,y))||(mouse_.isAtPosition(x,y)));
}
osstream&
MouseAndCatGame::toFile(ostream& os)
const
{
os<<setfill('0');<<set(2)<<mouse_.getX()<<"/"<<set(2)<<mouse_.Y()<<"/"<<setw(2)<<cat_.getX();<<"/"<<setw(2)<<cat_.getY();<<"/"<<setw(2)<<nut_.getX()<<"/"<<setw(2)<<nut_.getY()<<"/"<<setw(2)<<nut_.hasBeenCollected()<<"/";
}
istream&
MouseAndCatGame::FromFile(istream& is)
{
char ch;
is>>mouse_.x_>>ch>>mouse_.y_>>ch>>cat_.x_>>ch>>cat_.y_>>ch>>nut_.x_>>ch>>nut_.y_>>ch>>nut_.collected_>>ch;
return is;
}
ostream& operator <<(ostream& os const MouseAndCatGame& mcg)
{
return(mcg.toFile(os));
}
istream& operator>>(istream& is,MouseAndCatGame& mcg)
{
return(mcg.fromFile(is));
}