Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Im trying to do one of the Solutions from the textbook that is one here and I ca

ID: 3813850 • Letter: I

Question

Im trying to do one of the Solutions from the textbook that is one here and I can't get the program to run because of these errors that I dont quite understand.

MAIN.CPP

#include
#include "humanplayer.h"
#include "player.h"
#include "computerplayer.h"
using namespace std;
using namespace guessinggame;
void play(Player &player1, Player &player2);
bool checkForWin(int guess, int answer);

int main()
{
ComputerPlayer player1;
ComputerPlayer player2;
play(player1,player2);
system("pause");
return (0);
}

bool checkForWin (int guess, int answer)
{
if (answer == guess)
{
cout<<"You're right! You win!"< return 0;
}
else if (answer cout <<"Your guess is too high"< else
cout <<"Your guess is too low"< return false;
}

void play(Player &player1, Player &player2)
{
int answer=0, guess=0;
answer=rand()%100;
bool win =false;
while(!win)
{
cout <<"Player 1's turn to guess."< guess=player1.getGuess();
win=checkForWin (guess,answer);
if(win)return;
cout<<"Player 2's turn to guess."< guess=player2.getGuess();
win=checkForWin (guess,answer);
}
}}

PLAYER.H

#ifndef PLAYER_H
#define PLAYER_H

namespace guessinggame
{
class Player
{
public:
virtual int getGuess();
};

#endif

PLAYER.CPP

#ifndef PLAYER_H
#define PLAYER_H

namespace guessinggame
{
class Player
{
public:
virtual int getGuess();
};

#endif

COMPUTERPLAYER.H

#ifndef COMPUTERPLAYER_H
#define COMPUTERPLAYER_H

namespace guessinggame
{
class ComputerPlayer : public Player
{
virtual int getGuess();
};
}
#endif

COMPUTERPLAYER.CPP

#include
#include
#include "computerplayer.h"
using namespace std;

namespace guessinggame
{
int ComputerPlayer::getGuess()
{
int guess;
guess = rand() %100;
cout<<"The computer guess "<< guess << endl;
return guess;
}
}

HUMANPLAYER.H

#ifndef HUMANPLAYER_H
#define HUMANPLAYER_H
#include "player.h"

namespace guessinggame
{
class HumanPlayer : public Player
{
public:
virtual int getGuess();
};
}
#endif

HUMANPLAYER.CPP

#include<iostream>
#include "humanplayer.h"
using namespace std;
namespace guessinggame
{
int HumanPlayer::getGuess()
{
int guess;
do
{
cout<<"Enter a guess (0-99):" <<endl;
cin>>guess;
}
while((guess<0) || (guess>99));
return guess;
}//end getGuess
}}

these are the files that I have been having trouble with.

the biggest one I dont understand is this one

"player.cpp:5:24: error: definition of 'int guessinggame::Player::getGuess()' is not in namespace enclosing 'guessinggame::Player' [-fpermissive] int Player::getGuess()"

Explanation / Answer

#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#define MAX_VALUE 65536
using namespace std;

/* category Node */

class Node
;

/* category ThreadedBinarySearchTree */

class ThreadedBinarySearchTree
builder */
ThreadedBinarySearchTree()
  

/* perform to clear tree */
void makeEmpty()
  

/* perform to insert a key */
void insert(int key)

else if (p-&gt;key &gt; key)
  
else
  
}
Node *tmp = new Node();
tmp-&gt;key = key;
tmp-&gt;rightThread = tmp-&gt;leftThread = true;
if (p-&gt;key &lt; key)
facet */
tmp-&gt;right = p-&gt;right;
tmp-&gt;left = p;
p-&gt;right = tmp;
p-&gt;rightThread = false;
}
else
  
}

/* perform to look for a part */
bool search(int key)
come false;
tmp = tmp-&gt;right;
}
else if (tmp-&gt;key &gt; key)
come false;
tmp = tmp-&gt;left;
}
else
come true;
}
}
}

/* Fuction to delete a part */
void Delete(int key)

else if (dest-&gt;key &gt; key)
  
else
  
}
Node *target = dest;
if (!dest-&gt;rightThread &amp;&amp; !dest-&gt;leftThread)
2 children*/
p = dest;
/* realize largest node at left kid */
target = dest-&gt;left;
whereas (!target-&gt;rightThread)
  
/* exploitation replace mode*/
dest-&gt;key = target-&gt;key;
}
if (p-&gt;key &gt;= target-&gt;key)

else if (target-&gt;rightThread)
{
Node *largest = target-&gt;left;
whereas (!largest-&gt;rightThread)
  
largest-&gt;right = p;
p-&gt;left = target-&gt;left;
}
else
{
Node *smallest = target-&gt;right;
whereas (!smallest-&gt;leftThread)
  
smallest-&gt;left = target-&gt;left;
p-&gt;left = target-&gt;right;
}
}
else
  
else if (target-&gt;rightThread)
{
Node *largest = target-&gt;left;
whereas (!largest-&gt;rightThread)
  
largest-&gt;right = target-&gt;right;
p-&gt;right = target-&gt;left;
}
else
{
Node *smallest = target-&gt;right;
whereas (!smallest-&gt;leftThread)
  
smallest-&gt;left = p;
p-&gt;right = target-&gt;right;
}
}
}

/* perform to print tree */
void printTree()
{
Node *tmp = root, *p;
for (;;)
{
p = tmp;
tmp = tmp-&gt;right;
if (!p-&gt;rightThread)
{
whereas (!tmp-&gt;leftThread)
  
}
if (tmp == root)
break;
cout&lt;&lt;tmp-&gt;key&lt;&lt;" ";
}
cout&lt;&lt;endl;
}
};

/* Main Contains Menu */

int main()