-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.cpp
More file actions
50 lines (44 loc) · 1.48 KB
/
menu.cpp
File metadata and controls
50 lines (44 loc) · 1.48 KB
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
45
46
47
48
49
50
#include "menu.h"
#include <iostream>
#include <algorithm>
using namespace std;
Menu::Menu() {}
void Menu::addMenuItem(int itemID, const string& itemDetails) {
items[itemID] = itemDetails;
cout << "Menu Item Added: " << itemID << " - " << itemDetails << "\n";
}
void Menu::updateMenuItem(int itemID, const string& updatedDetails) {
if (items.find(itemID) != items.end()) {
items[itemID] = updatedDetails;
cout << "Menu Item Updated: " << itemID << " - " << updatedDetails << "\n";
} else {
cout << "Menu Item ID not found!\n";
}
}
string Menu::getMenuItemDetails(int itemID) const {
if (items.find(itemID) != items.end()) {
return items.at(itemID);
}
return "Item not found!";
}
vector<pair<int, string>> Menu::filterMenu(const vector<string>& allergens) const {
vector<pair<int, string>> filteredMenu;
for (const auto& item : items) {
bool containsAllergen = false;
for (const auto& allergen : allergens) {
if (item.second.find(allergen) != string::npos) {
containsAllergen = true;
break;
}
}
if (!containsAllergen) {
filteredMenu.push_back(item);
}
}
return filteredMenu;
}
void Menu::displayMenu(const vector<pair<int, string>>& menuToDisplay) const {
for (const auto& item : menuToDisplay) {
cout << item.first << ": " << item.second << "\n";
}
}