void Player::gameStart()
{
bool enterNameLoopEnd = false;
int satisfied;
cout << "Welcome to the game we are pleased to see a new" << endl;
cout << "recruit join our ranks. We have a special mission" << endl;
cout << "for you, we need you to hack into bank accounts all" << endl;
cout << "across the world and take them for everything they have!" << endl;
cout << "Now please enter your name\n" << endl;
cout << "Name: ";
while(enterNameLoopEnd != true)
{
getline(cin, name);
if(name.empty())
{
cout << "You must enter a name!" << endl;
cout << "Name: ";
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
cout << "Are you satisfied with the name " << name << "?" << endl;
cout << "1) Yes" << endl;
cout << "2) No" << endl;
cin >> satisfied;
//The code below is error handling so if the user enters an undesired input
//then the program wont flip out.
if(satisfied == 1)
{
break;
}
elseif(satisfied == 2)
{
cout << "Ok please enter the name you wish to use\n" << endl;
cout << "Name: ";
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
else
{
cout << "Invalid response please enter the name you wish to use\n" << endl;
cout << "Name: ";
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
}
cout << "\nOk " << name << " were going to start you" << endl;
cout << "off with $1200.\n" << endl;
cout << "Dont forget to save from the main menu or else your progress" << endl;
cout << "will not be saved!!\n" << endl;
cin.get();
cin.clear();
mainGame();
}