-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecipeMakerUI.java
More file actions
96 lines (76 loc) · 3.04 KB
/
Copy pathRecipeMakerUI.java
File metadata and controls
96 lines (76 loc) · 3.04 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
import java.util.Scanner;
import java.util.ArrayList;
import java.io.*;
public class RecipeMakerUI {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) throws IOException {
//Variables
ArrayList<String> recipeList = new ArrayList<String>();
String choice;
final String CREATE = "CREATE";
final String COPY = "COPY";
final String PRINT = "PRINT";
final String LISTALL = "LISTALL";
final String UPDATE = "UPDATE";
final String DELETE = "DELETE";
final String QUIT = "QUIT";
RecipeMaker myRecipeMaker = new RecipeMaker();
myRecipeMaker.makeRecipeList(recipeList);
File folder = new File("Recipes").getAbsoluteFile();
if (!folder.exists()) {
return;
}
do {
mainMenu();
System.out.print("Enter the command of the option you want: ");
choice = keyboard.nextLine();
System.out.println();
if (choice.equalsIgnoreCase(CREATE)) {
myRecipeMaker.createRecipe(recipeList);
continuePrompt();
}
else if (choice.equalsIgnoreCase(COPY)) {
myRecipeMaker.copyRecipe(recipeList);
continuePrompt();
}
else if (choice.equalsIgnoreCase(PRINT)) {
myRecipeMaker.printRecipe(recipeList);
continuePrompt();
}
else if (choice.equalsIgnoreCase(LISTALL)) {
myRecipeMaker.listRecipes(recipeList);
continuePrompt();
}
else if (choice.equalsIgnoreCase(UPDATE)) {
myRecipeMaker.updateRecipe(recipeList);
continuePrompt();
}
else if (choice.equalsIgnoreCase(DELETE)) {
myRecipeMaker.deleteRecipe(recipeList);
continuePrompt();
}
else if (choice.equalsIgnoreCase(QUIT)) {
System.out.println("Quitting... ");
}
else {
System.out.println("Not a valid choice. Please try again.");
}
} while (!choice.equalsIgnoreCase("QUIT"));
}
public static void mainMenu() {
System.out.println();
System.out.println("--------RecipeMaker.java (Dedicated to my mom)--------");
System.out.println("CREATE = Create new recipe");
System.out.println("COPY = Make copy of existing recipe");
System.out.println("PRINT = Print existing recipe");
System.out.println("LISTALL = List all recipes");
System.out.println("UPDATE = Update recipe");
System.out.println("DELETE = Delete recipe");
System.out.println("QUIT = Quit program");
System.out.println();
}
public static void continuePrompt() {
System.out.print("Press enter to continue... ");
keyboard.nextLine();
}
}