A drunken man gets out of a bar and is so drunk that he will take one step at a time, left or right at random. At some distance on the left is his house, and somewhere on the right, an ice-cold river.
Write a program to ask the user input the initial position p of the man. Assume his house is at position 0, and the river is at position 10. If the initial position is at 3, then after 3 successive left steps, he arrives home. Or, after 7 successive right steps, he falls into the river.
Define a class Man as follows, and use it in your main program to simulate the drunken man walking problem.
class Man
{
public:
Man(int p = 5);
void show() const;
void left();
void right();
bool gameover();
private:
int position;
};