forked from khanaaziz1/Hacktoberfest_2019
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Recipe.java
145 lines (120 loc) · 3.2 KB
/
Recipe.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
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
/**
* Write a description of class Recipe here.
*
* @author ()
* @version (Final)
*/
public class Recipe
{
// instance variables -
private String recipeName;// the name of the recipe
private String recipeid;//the recipe id
private String origin;//the place wehere the recipe originates
private String category;// which category the recipe is bread or cakes etc
private String description;//what the recipe is about
private String ingredients;//what makes up the recipe
private String instructions;//how to use the recipe to prepare a dish
/**
* Constructor for objects of class Recipe
* +recipeName
* +recipeid
* +origin
* +category
* +category
* +description
* +ingredients
* +instructions
*
*/
public Recipe(String recipeName,String origin, String category, String description ,String ingredients, String instructions )
{
this.recipeName=recipeName;
this.origin=origin;
this.category=category;
this.description=description;
this.ingredients=ingredients;
this.instructions=instructions;
this.recipeid=CreateRecipeId(category);
}
/**
* method generates a code for an recipe
* @param -type of item =>String
* @return -the randomly generated code=>String
*/
public String CreateRecipeId(String category){
return category.substring(0,3) + (int)Math.random()*9999+1;
}
/**
/**
* mutator methods-assign given attributes to given values
* @param -new Values
* @return -void
*/
public void setRecipeName(String recipeName)
{
this.recipeName=recipeName;
}
public void SetOrigin(String origin)
{
this.origin=origin;
}
public void setCategory(String category)
{
this.category=category;
}
public void setDescription(String description)
{
this.description=description;
}
public void setIngredients(String ingredients)
{
this.ingredients=ingredients;
}
public void setInstructions(String instructions)
{
this.instructions=instructions;
}
/**
* retriever methods-returns values held by instance variables
* @param -none
* @return -type of variable being sought
*/
public String getRecipeName()
{
return this.recipeName;
}
public String getOrigin()
{
return this.origin;
}
public String getCategory()
{
return this.category;
}
public String getDescription()
{
return this.category;
}
public String getIngredients()
{
return this.ingredients;
}
public String getInstructions()
{
return this.instructions;
}
public String getCreateRecipeId()
{
return this.recipeid;
}
/**
* toString()-print format of this item
* @param none
* @overides java.lang.Object.toString()
*/
public String toString()
{
return "RecipeName: "+recipeName+"\nRecipeID: "+recipeid+"\nOrigin: "+origin+"\nCategory: "+category+"\nDescription: "+description+
"\nIngredients: "+ingredients+"\nInstructions: "+instructions;
}
}