/Users/e1818782/NetBeansProjects/IA Stuff/RecipeDatabase_Nicolas/src/nicolas/Recipe.java |
1
2
3
4
5
6 package nicolas;
7
8 import java.util.ArrayList;
9
10
11
12 @author
13
14 public class Recipe {
15
16 int calories=10;
17 String name;
18 String method;
19 double price;
20 double servings;
21 double cost=-1;
22 boolean isMissingCost=false;
23
24 String notes;
25 ArrayList<Ingredients> ing = new ArrayList<>();
26
27 public Recipe(int calories, String name, double price, double servings,double cost, String method, ArrayList<Ingredients>ing)
28 {
29 this.name=name;
30 this.calories=calories;
31 this.price=price;
32 this.servings=servings;
33
34 this.cost=cost;
35 this.method=method;
36 this.ing=ing;
37 }
38 public Recipe()
39 {
40
41 }
42
43 public double getPMargin()
44 {
45 return (price/cost) *100;
46 }
47 public double getConversion(double desired)
48 {
49 return (desired/servings);
50 }
51 public String getName()
52 {
53 return name;
54 }
55 public double getPrice()
56 {
57 return price;
58 }
59 public int getCalories()
60 {
61 return calories;
62 }
63 public double getCost()
64 {
65
66 return cost;
67 }
68 public double getServings()
69 {
70 return servings;
71 }
72 public String getMethod()
73 {
74 return method;
75 }
76 public ArrayList<Ingredients> convertServings (double newServe)
77 {
78
79 ArrayList<Ingredients> temp = new ArrayList<>();
80
81 double multiplier= newServe/servings;
82 for (int i=0; i<ing.size();i++ )
83 {
84
85 temp.get(i).setQuantity(ing.get(i).getQuantity()*multiplier);
86
87 }
88 return temp;
89 }
90 public void setIng(ArrayList<Ingredients> ing)
91 {
92 this.ing=ing;
93 cost=0;
94 for(int c=0; c<ing.size();c++)
95 {
96 if(ing.get(c).getCost()==-1)
97 {
98 isMissingCost=true;
99 }
100 else{
101
102 cost+=ing.get(c).getCost();
103 }
104 }
105
106 }
107 public void setName(String name)
108 {
109 this.name=name;
110 }
111 public void setServings (Double servings)
112 {
113 this.servings=servings;
114 }
115 public void setMethod (String method)
116 {
117 this.method=method;
118 }
119 public void setCalories(int calories)
120 {
121 this.calories=calories;
122 }
123 public void setPrice(double price)
124 {
125 this.price=price;
126 }
127 public ArrayList<Ingredients> getIng()
128 {
129 return ing;
130 }
131 }
132