int find(string restaurantName, vector<string> restaurants)
{
for (int i = 0; i < restaurants.size(); i++)
{
if (restaurantName == restaurants[i])
{
return i;
}
}
return NOT_FOUND;
}
void addRestaurant(string restaurantName, vector<string>&restaurants)
{
int found = find(restaurantName, restaurants);
if (found == NOT_FOUND)
{
restaurants.push_back(restaurantName);
cout << "The restaurant " << restaurantName << " was added to the vector" << endl;
}
else
{
cout << "The restaurant " << restaurantName << " was not added because it already is there" << endl;
}
}
void printMenu()
{
cout << "1 - Display all restaurant" << endl;
cout << "2 - Add a restaurant" << endl;
cout << "3 - Remove a restaurant" << endl;
cout << "4 - Shuffle the vector" << endl;
cout << "5 - Begin the tournament" << endl;
cout << "6 - Quit the program" << endl;
}
int readMenuChoice()
{
int choice = 0;
cin >> choice;
string garbage = "";
getline(cin, garbage);
return choice;
}
void printRestaurants(vector<string>&restaurants)
{
for (int i = 0; i < restaurants.size(); i++)
{
if (i < restaurants.size() - 1)
{
cout << restaurants[i] << ",";
}
else
cout << restaurants[i];
}
}
void removeRestaurant(string restaurantName, vector<string>&restaurants)
{
int found = find(restaurantName, restaurants);
if (found != NOT_FOUND)
{
int last_position = restaurants.size() - 1;
restaurants.erase(restaurants.begin() + found);
cout << "The restaurant " << restaurantName << " was removed from the vector"<< endl;
}
else
{
cout << "The restaurant " << restaurantName << " was not removed because it was already in the vector" << endl;
}
}
void removeLoserRestaurant(string restaurantName, vector<string>& restaurants)
{
int found = find(restaurantName, restaurants);
if (found != NOT_FOUND)
{
int last_position = restaurants.size() - 1;
restaurants.erase(restaurants.begin() + found);
}
else
{
cout << "The restaurant " << restaurantName << " was not removed because it was not in the vector" << endl;
}
}
}
if (winner == opponent1)
{
restaurantName = opponent2;
losers.push_back(restaurantName);
}
else if (winner == opponent2)
{
restaurantName = opponent1;
losers.push_back(restaurantName);
}
}
for (int i = 0; i < losers.size(); i++)
{
restaurantName = losers[i];
removeLoserRestaurant(restaurantName, restaurants);
}
losers.clear();
printRestaurants(restaurants);
} while (restaurants.size() > 1);
cout << "The winner is " << restaurants[0] << endl;
}
else
{
cout << "Could not begin tournament. There is not enough restaurants in the tournament. Please add or remove a restaurant." << endl;
}
return restaurantName;
}
Line 16: Your function prototype for addRestaurant() states it takes one argument.
Line 46: You call addRestaurant() with two arguments. Your call must agree with the function prototype.
Line 17,53: Ditto for removeRestaurant().
Line 195: call to log () argument type is ambiguous. Argument type is unsigned int, but there is no overload of log() for unsigned int.
Line 196: ditto.
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.