1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
while(userIn != "stop")
{
cout << endl << "Thank you! ";
bool read = read_rect(promptNextRec, invError, usedError, userIn, list);
while(read == false)
{
cout << endl << "Try again! ";
read = read_rect(promptNextRec, invError, usedError, userIn, list);
}
bool read_rect(const string prompt, const string invError, const string usedError, string & userName, vector <Rectangle> & list)
{
cout << prompt;
getline(cin, userName);
if(userName == "stop")
{
return true;
}
else if(userName.substr(0,4) != "rec ")
{
cout << invError;
return false;
}
else
{
int j(0);
for(int i = 0; i < list.size(); i++)
{
if(userName == "rec " + list[i].getName())
{
j++;
}
}
if(j != 0)
{
cout << usedError;
return false;
}
if(j == 0)
{
return true;
}
}
}
|