-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunFoodFinder.java
More file actions
194 lines (173 loc) · 5.81 KB
/
FunFoodFinder.java
File metadata and controls
194 lines (173 loc) · 5.81 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
190
191
192
193
194
import java.util.*;
/**
* This class has instance fields that record the specifications
* of the user. It creates an AllRecipesParser object and
* uses these specifications to output the list of websites that
* fit the user's requirements.
*/
public class FunFoodFinder {
// Meal Type (Breakfast, Lunch, Dinner, Snacks, etc.)
private String mtype;
// Ingredients to include
private String ingred;
// Ingredients to exclude
private String exclude;
// Sort by
private String sortBy;
// Dietary Restrictions
private TreeSet<String> dietR;
// Foods that must be excluded due to dietary Restrictions
private String foodsInDietR;
// recipe titles and urls to return
//private Map<String, String> recipes;
private String[] recipeTitles;
private String[] recipeUrls;
private Map<String, String[]> recipeData;
private String[] starInfo;
private String[] timeInfo;
private String[] calorieInfo;
public FunFoodFinder() {
this.mtype = "";
this.ingred = "";
this.exclude = "";
this.sortBy = "";
this.foodsInDietR = "";
this.dietR = new TreeSet<>();
//this.recipes = new HashMap<>();
this.recipeTitles = new String[1];
recipeTitles[0] = "recipe1";
}
// some function that creates a parser website,
// calls methods, and then returns all the websites
// that fit the specifications of the user
public String getMtype() {
return this.mtype;
}
public String getIngred() {
return this.ingred;
}
public String getExclude() {
return this.exclude;
}
public String getSortBy() {
return this.sortBy;
}
public TreeSet<String> getDietR () {
TreeSet<String> dietRCopy = new TreeSet<>();
for (String s: this.dietR) {
dietRCopy.add(s);
}
return dietRCopy;
}
public void setDietR(String food) {
if (dietR.size() == 0) {
dietR = new TreeSet<>();
}
dietR.add(food);
}
public void removeDietR(String food) {
if (dietR.size() > 0 && dietR.contains(food)) {
dietR.remove(food);
}
}
// semma's
public void setFoodsInDietR() {
if (dietR.contains("Vegan") || dietR.contains("Vegetarian")) {
foodsInDietR += "beef, pork, chicken, turkey, duck, shrimp, fish, " +
"gelatin, tilapia, cod, lamb, crab, clam, lobster";
}
if (dietR.contains("Vegan") || dietR.contains("Lactose")) {
foodsInDietR += "milk, cheese, yogurt, butter, cream, mayonnaise, chocolate";
}
if (dietR.contains("Vegan")) {
foodsInDietR += "eggs, honey";
}
if (dietR.contains("Gluten")) {
foodsInDietR += "bread, pasta, biscuits, crackers, flour, couscous, wheat, oats, chips";
}
if (dietR.contains("Nuts")) {
foodsInDietR += "nuts, peanuts, cashews, tree nuts, almonds, walnuts," +
" hazelnuts, pecans, macadamias, pistachios, chestnuts";
}
}
public String getFoodsInDietR() {
return foodsInDietR;
}
public void setMtype(String mtype) {
this.mtype = mtype;
// System.out.println(mtype);
}
public void setIngred(String ingred){
this.ingred = ingred;
//System.out.println(ingred);
}
public void setExclude(String exclude) {
this.exclude = exclude;
//System.out.println(exclude);
}
public void setSortBy(String sortBy) {
this.sortBy = sortBy;
}
public void setStarInfo(Set<String> ratings) {
String[] starRats = new String[ratings.size()];
int index = 0;
for (String val: ratings) {
//System.out.println("in setRecipes " + rec);
starRats[index] = val;
index++;
}
starInfo = starRats;
}
public void setRecipes(Set<String> titles) {
// if (recipes.size() == 0) {
// this.recipes = new HashMap<>();
// }
//System.out.println("setting recipes" + titles.size());
// set recipes here
String[] recipes = new String[titles.size()];
int index = 0;
for (String rec: titles) {
//System.out.println("in setRecipes " + rec);
recipes[index] = rec;
index++;
}
recipeTitles = recipes;
}
public String[] getRecipes() {
String[] recTitlesCopy = new String[recipeTitles.length];
System.arraycopy(recipeTitles, 0, recTitlesCopy, 0, recipeTitles.length);
// for (int i = 0; i < recTitlesCopy.length; i++) {
// System.out.println("rec in getR " + recTitlesCopy[i]);
// }
return recTitlesCopy;
}
public void setRecipeUrls(Collection<String> urls) {
// if (recipes.size() == 0) {
// this.recipes = new HashMap<>();
// }
//System.out.println("setting recipes" + titles.size());
// set recipes here
String[] recUrls = new String[urls.size()];
int index = 0;
for (String rec: urls) {
//System.out.println("in setRecipes " + rec);
recUrls[index] = rec;
index++;
}
recipeUrls = recUrls;
}
public String[] getRecipeUrls() {
String[] recUrlsCopy = new String[recipeUrls.length];
System.arraycopy(recipeUrls, 0, recUrlsCopy, 0, recipeUrls.length);
// for (int i = 0; i < recTitlesCopy.length; i++) {
// System.out.println("rec in getR " + recTitlesCopy[i]);
// }
return recUrlsCopy;
}
public void setRecipeData(Map<String, String[]> recipeData) {
this.recipeData = recipeData;
}
public String getRecipeDataCell(String recName, int index) {
return this.recipeData.get(recName)[index];
}
}