fix: Only display Invalid Index in listMenuItems() and addMenuItems() if owner has any restaurants

This commit is contained in:
Joel Thomas
2026-02-20 09:47:38 +05:30
parent 1fb2e57404
commit 184ea60c08
@@ -377,7 +377,7 @@ void FoodDeliveryController::listMenuItems() const
<< "\n";
}
}
else
else if (!restaurantOwner.getRestaurants().empty())
{
std::cout << "Invalid Index. Cannot display Menu Items!\n";
return;
@@ -415,7 +415,7 @@ void FoodDeliveryController::addMenuItem() const
restaurantIterator->second->addMenuItem(menuItem);
std::cout << "Added new Menu Item " << menuItem.getName() << " with ID " << menuItem.getId() << " to Restaurant " << restaurantIterator->second->getName() << " successfully\n";
}
else
else if (!restaurantOwner.getRestaurants().empty())
{
std::cout << "Invalid Index. Cannot add new Menu Item!\n";
return;