-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
189 lines (170 loc) · 6.19 KB
/
main.cpp
File metadata and controls
189 lines (170 loc) · 6.19 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#include "IIKH.h"
#include "trim.h"
#include <iostream>
#include <string>
#define RecipeInfo "recipeInfo.txt"
#define PlanInfo "planInfo.txt"
#undef max
using namespace std;
int main() {
Greeter greeter;
greeter.displayWelcomeScreen();
RecipeList recipeList(RecipeInfo);
int option = 0;
while (option < 7) {
cout << "[INTERACTIVE INTELLIGENT KITCHEN HELPER]\n------------------\n";
cout << "1.VIEW MENU\n2.SEARCH RECIPE\n3.ADD RECIPE\n4.MEAL PLAN\n5.RANDOM RECOMMEND\n6.QUIT\n";
cout << "------------------\n";
cout << "SELECT AN OPTION: ";
cin >> option;
cout << endl;
greeter.clearScreen();
//View
if (option == 1) {
int viewOption = 0;
cout << "VIEW OPTIONS\n";
cout << "------------------\n";
cout << "1. VIEW ALL MENU\n";
cout << "2. VIEW MAIN MENU\n";
cout << "3. VIEW SIDE MENU\n";
cout << "------------------\n";
cout << "SELECT A VIEW OPTION: ";
cin >> viewOption;
cout << endl;
if (viewOption == 1) {
recipeList.printAllTitles();
}
else if (viewOption == 2) {
recipeList.printMainTitles();
}
else if (viewOption == 3) {
recipeList.printSideTitles();
}
else {
cout << "INVALID SEARCH OPTION.\n";
}
}
//Search
else if (option == 2) {
int searchOption = 0;
cout << "SEARCH OPTIONS\n";
cout << "------------------------\n";
cout << "1. SEARCH BY MENU NAME\n";
cout << "2. SEARCH BY INGREDIENT\n";
cout << "3. SEARCH BY HASHTAG\n";
cout << "4. SEARCH BY CALORIES\n";
cout << "------------------------\n";
cout << "SELECT A SEARCH OPTION: ";
cin >> searchOption;
if (searchOption == 1) {
cout << "ENTER THE MENU NAME: ";
cin.ignore(numeric_limits<streamsize>::max(), '\n');
string menuname;
getline(cin, menuname);
recipeList.searchName(recipeList.recipeDB, menuname);
}
else if (searchOption == 2) {
cout << "ENTER AN INGREDIENT TO SEARCH FOR: ";
string ingreKeyword;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
getline(cin, ingreKeyword);
recipeList.search(recipeList.recipeDB, "INGREDIENT", ingreKeyword);
}
else if (searchOption == 3) {
cout << "ENTER TAG TO SEARCH: ";
string tagKeyword;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
getline(cin, tagKeyword);
recipeList.search(recipeList.recipeDB, "HASHTAG", tagKeyword);
}
else if (searchOption == 4) {
cout << "ENTER CALORIE LIMIT: ";
string calorieLimit;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
getline(cin, calorieLimit);
recipeList.search(recipeList.recipeDB, "CALORIE", calorieLimit);
}
else {
cout << "INVALID SEARCH OPTION.\n";
}
}
// Add
else if (option == 3) {
string newRecipe;
cout << "EXAMPLE : <main> <menu> <ingredient1, ingredient2> <10:10> <1. step1; 2. step2; 3. step3> <111> <#hot; #kids>\n";
cout << "ENTER THE RECIPE YOU WANT TO ADD: \n";
cin.ignore(numeric_limits<streamsize>::max(), '\n');
getline(cin, newRecipe);
recipeList.add(newRecipe, RecipeInfo);
}
// Meal plan
else if (option == 4) {
int planOption = 0;
cout << "MEAL PLAN OPTIONS\n";
cout << "--------------\n";
cout << "1. VIEW PLANS\n";
cout << "2. ADD PLAN\n";
cout << "--------------\n";
cout << "SELECT AN OPTION: ";
cin >> planOption;
if (planOption == 1) {
cout << endl;
PlanManager planManager;
planManager.readPlanInfo(PlanInfo);
}
else if (planOption == 2) {
string newPlan;
cout << "EXAMPLE : <CAU anniversary> <11/3> <b; recipe3; 4> <l; recipe1; 2> <l; recipe3; 2> <d; recipe4; 5> \n";
cout << "ENTER THE PLAN YOU WANT TO ADD: \n";
cin.ignore(numeric_limits<streamsize>::max(), '\n');
getline(cin, newPlan);
PlanManager planManager;
planManager.writePlanInfo(PlanInfo, newPlan);
}
else {
cout << "INVALID PLAN OPTION.\n";
}
}
// Random recommend
else if (option == 5) {
int popOption = 0;
cout << "RANDOM RECOMMEND OPTIONS\n";
cout << "------------------\n";
cout << "1. BY # OF PEOPLE\n";
cout << "2. IN MAIN MENU\n";
cout << "3. IN SIDE MENU\n";
cout << "------------------\n";
cout << "SELECT AN OPTION: ";
cin >> popOption;
if (popOption == 1) {
Meal meal(recipeList.mainRecipeDB, recipeList.sideRecipeDB);
}
else if (popOption == 2) {
Meal meal(recipeList.mainRecipeDB);
}
else if (popOption == 3) {
Meal meal(recipeList.sideRecipeDB);
}
else {
cout << "INVALID RECOMMEND OPTION.\n";
}
}
// Quit
else if (option == 6) {
greeter.displayGoodbyeScreen();
return 0;
}
// Other number
else {
cout << "WRONG NUMBER CHOICE\n";
}
// Clear console
if (option != 6) { // Except "quit"
cout << "\nPRESS ENTER TO CONTINUE...";
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cin.get(); // Wait for enter
system("cls");
}
}
return 0;
}