-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateRecipe.java
More file actions
81 lines (64 loc) · 2.38 KB
/
createRecipe.java
File metadata and controls
81 lines (64 loc) · 2.38 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
import java.util.Scanner;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
//As a user I want to be able to create recipes in the recipe book with the ingredient list and a step by step instruction so that I can store and recreate them easily
//Acceptance Criteria:
//Being able to add a name, a description, an ingredient list, and step-by-step cooking instructions
//Makes sure all inputs are completed
//Automatically saves the recipe
class createRecipe{
Scanner scan = new Scanner(System.in);
//title
public void recipeTitle(Recipe recipe){
System.out.println("Please enter the title of the recipe:");
String recipeTitle = scan.nextLine();
recipe.settitle(recipeTitle);
}
//description
public void recipeDescription(Recipe recipe){
System.out.println("Please enter the description of the recipe:");
String receipeDescription = scan.nextLine();
recipe.setdescription(receipeDescription);
}
//ingredient list
public void ingrdList(Recipe recipe) {
System.out.println("Please enter your ingredients one by one (Enter 'done' when you are done): ");
boolean x = true;
while (x) {
String userIng = scan.nextLine();
if (userIng.equals("done")) {
break;
} else {
recipe.addingredient(userIng);
}
}
}
//Instructions
public void instructions(Recipe recipe) {
System.out.println("Please enter your instructions one by one (Enter 'done' when you are done): ");
boolean x = true;
while (x) {
String userInstructions = scan.nextLine();
if (userInstructions.equals("done")) {
x = false;
} else {
recipe.addinstructions(userInstructions);
}
}
}
public Recipe callAll()throws IOException {
createRecipe alsoAFiller = new createRecipe();
Recipe recipe = new Recipe();
//Calling all methods
alsoAFiller.recipeTitle(recipe);
alsoAFiller.recipeDescription(recipe);
alsoAFiller.ingrdList(recipe);
alsoAFiller.instructions(recipe);
return recipe;
}
}