-
Notifications
You must be signed in to change notification settings - Fork 0
/
exe.java
64 lines (42 loc) · 1.26 KB
/
exe.java
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
package recipe;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.mashape.unirest.http.exceptions.UnirestException;
public class exe {
public static void main(String[] args) throws UnirestException
{
spoonacular x = new spoonacular();
//System.out.println(x.findRecipeByIngredient("Cheese"));
List<FoodRecipe> z = new ArrayList<>();
ArrayList<String> ings = new ArrayList<String>();
ings.add("Pasta");
ings.add("Prawns");
String listString = "";
for (int i=0; i<ings.size();++i)
{
if(i != ings.size()-1){
listString += ings.get(i) + "%2C";
}
else{
listString += ings.get(i);
}
}
//System.out.println(listString);
//z = x.findRecipeByIngredient("Flour");
z = x.findRecipeByIngredient(listString);
System.out.println(z.get(0).getTitle());
System.out.println(z.get(0).getId());
int id = z.get(0).getId();
//System.out.println(Arrays.toString(z.toArray()));
List<AnalyzedRecipe> result = new ArrayList<>();
result = x.getRecipe(id);
if(result.size() > 0)
{
System.out.println(result.get(0).getSteps());
}
else{
System.out.println("No recipe available.");
}
}
}