-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.java
More file actions
232 lines (216 loc) · 8.12 KB
/
Menu.java
File metadata and controls
232 lines (216 loc) · 8.12 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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
import java.util.Scanner;
/**
* Write a description of class Menu here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Menu
{
/**
* A default constructor for objects of class Menu.
*/
public Menu()
{
}
/**
* Create a changeCustomerInformation method to display the change product information menu page.
*/
public char changeCustomerInformation()
{
System.out.println("Change name enter \"A\"");
System.out.println("Change email enter \"B\"");
System.out.println("Change password enter \"C\"");
System.out.println("Change phone enter \"D\"");
System.out.println("Change address enter \"E\"");
System.out.println("Exist enter \"X\"");
return getChoice('E');
}
/**
* Create a changeOwnerInformation method to display the change owner information page.
*/
public char changeOwnerInformation()
{
System.out.println("Change name enter \"A\"");
System.out.println("Change email enter \"B\"");
System.out.println("Change password enter \"C\"");
System.out.println("Exist enter \"X\"");
return getChoice('C');
}
/**
* Create a customerMenu method to display the customer menu page.
*/
public char customerMenu()
{
System.out.println("Add product to cart enter \"A\"");
System.out.println("Delete product from cart enter \"B\"");
System.out.println("Check out enter \"C\"");
System.out.println("View product enter \"D\"");
System.out.println("View cart enter \"E\"");
System.out.println("Search product enter \"F\"");
System.out.println("View transcation enter \"G\"");
System.out.println("View and change personal information enter \"H\"");
System.out.println("Unregister enter \"I\"");
System.out.println("Exit enter \"X\"");
return getChoice('I');
}
/**
* Create a editProduct method to display the edit product page.
*/
public char editProduct()
{
System.out.println("Edit Product Name Enter \"A\"");
System.out.println("Edit Selling Option Enter \"B\"");
System.out.println("Edit Category Enter \"C\"");
System.out.println("Edit Inventory Amount Enter \"D\"");
System.out.println("Edit Origin Enter \"E\"");
System.out.println("Edit Shelf Life Enter \"F\"");
System.out.println("Edit Discount Enter \"G\"");
System.out.println("Exit Enter \"X\"");
return getChoice('G');
}
/**
* Create a exitPage method to exit the page.
*/
public void exitPage()
{
System.out.println("Thanks for using Monash Fruit and Vegetable system.");
System.out.println("Have a nice day!");
}
/**
* Create a getChoice method to get the user inputting choice.
*/
public char getChoice(char endOption)
{
Scanner console = new Scanner(System.in);
String option = console.nextLine().toUpperCase().trim();
while (!(option.length() == 1 && ((option.charAt(0) >= 'A' && option.charAt(0) <= endOption) || option.charAt(0) == 'X')))
{
System.out.println("Input invalid. Please choose A..." + endOption + " or X.");
option = console.nextLine().toUpperCase().trim();
}
return option.charAt(0);
}
/**
* Create a getChoiceWithoutExit method to get the user inputting choice without exit.
*/
public char getChoiceWithoutExit(char endOption)
{
Scanner console = new Scanner(System.in);
String option = console.nextLine().toUpperCase().trim();
while (!(option.length() == 1 && ((option.charAt(0) >= 'A' && option.charAt(0) <= endOption))))
{
System.out.println("Input invalid. Please choose A..." + endOption);
option = console.nextLine().toUpperCase().trim();
}
return option.charAt(0);
}
/**
* Create a inventoryUnit method to display the inventory unit entering page.
*/
public char inventoryUnit()
{
System.out.println("Please choose inventory unit(Enter \"X\" to cancel):");
System.out.println("Inventory Unit by weight enter \"A\"");
System.out.println("Inventory Unit by amount enter \"B\"");
return getChoice('B');
}
/**
* Create a mainMenu method to display the menu page.
*/
public char mainMenu()
{
System.out.println("Administrator Login Enter \"A\"");
System.out.println("Customer Login Enter \"B\"");
System.out.println("Customer Register Enter \"C\"");
System.out.println("Enter System Enter \"D\"");
System.out.println("Exit enter \"X\"");
return getChoice('D');
}
/**
* Create a ownerMenu method to display the owner menu page.
*/
public char ownerMenu()
{
System.out.println("Add product enter \"A\"");
System.out.println("Delete product enter \"B\"");
System.out.println("View product enter \"C\"");
System.out.println("Edit product enter \"D\"");
System.out.println("Search product enter \"E\"");
System.out.println("View customer enter \"F\"");
System.out.println("View transcation enter \"G\"");
System.out.println("View and change personal information enter \"H\"");
System.out.println("Exit enter \"X\"");
return getChoice('H');
}
/**
* Create a searchProductMenu method to display the search product menu page.
*/
public char searchProductMenu()
{
System.out.println("\u000c");
System.out.println("Search By Product Name Enter \"A\"");
System.out.println("Search By Category Enter \"B\"");
System.out.println("Search By Origin Enter \"C\"");
System.out.println("Search By Discount Enter \"D\"");
System.out.println("Exit Enter \"X\"");
return getChoice('D');
}
/**
* Create a sellingOptionByAmount method to display the selling option amount choose page.
*/
public char sellingOptionByAmount()
{
System.out.println("Please choose selling opion by amount: ");
System.out.println("Sell by whole enter \"A\"");
System.out.println("Sell by half enter \"B\"");
return getChoiceWithoutExit('B');
}
/**
* Create a sellingOptionByWeight method to display the selling option weight choose page.
*/
public char sellingOptionByWeight()
{
System.out.println("Please choose selling opion by weight: ");
System.out.println("Sell by kg enter \"A\"");
System.out.println("Sell by buntch enter \"B\"");
System.out.println("Sell by bag enter \"C\"");
return getChoiceWithoutExit('C');
}
/**
* Create a unloggedInMenu method to display the unlogged in menu page.
*/
public char unloggedInMenu()
{
System.out.println("Add product to cart enter \"A\"");
System.out.println("Delete product from cart enter \"B\"");
System.out.println("Check out enter \"C\"");
System.out.println("View product enter \"D\"");
System.out.println("View cart enter \"E\"");
System.out.println("Search product enter \"F\"");
System.out.println("Administrator Login Enter \"G\"");
System.out.println("Customer Login Enter \"H\"");
System.out.println("Customer Register Enter \"I\"");
System.out.println("Exit enter \"X\"");
return getChoice('I');
}
/**
* Create a viewProductMenu method to display the product menu page.
*/
public char viewProductMenu()
{
System.out.println("\u000c");
System.out.println("View all products \"A\"");
System.out.println("View products by cateloge \"B\"");
System.out.println("View products by price \"C\"");
return getChoice('C');
}
/**
* Create a welcomePage method to display the welcome page.
*/
public void welcomePage()
{
System.out.println("Welcome to Monash Fruit and Vegetable system.");
System.out.println("Enjoy your shopping time!");
}
}