-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrderSystem.java
More file actions
173 lines (107 loc) · 3 KB
/
OrderSystem.java
File metadata and controls
173 lines (107 loc) · 3 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
/*
* Matthew Homan
* Assignment 2: Inheritance and Encapsulation
* April 11, 2023
* CMIS 242 7382
* Spring 2023
*
* This program allows a user to order a salty or fruit snack and choose from additional options.
* It then calculates the price and displays the order.
*
*/
import java.util.Scanner;
public class OrderSystem {
static Scanner userInput = new Scanner(System.in);
static Scanner sizeInput = new Scanner(System.in);
public static void displayMenu() {
System.out.print("\nMENU");
System.out.print("\n1: Order Snack");
System.out.print("\n2: Exit Program");
System.out.print("\nEnter your selection: ");
}
public static void displaySubmenu() {
System.out.print("\nDo you want Fruit Snack (1) or Salty Snack (2): ");
}
public static void displaySizeMenu() {
System.out.print("\nWhat size do you want: S, M, or L: ");
}
public static void processMenuSelection(int userSelection) {
if (userSelection == 1) {
displaySubmenu();
} else if(userSelection == 2) {
System.out.println("\nThank you for using the program. Goodbye!");
} else {
System.out.println("Invalid choice. Goodbye.");
}
}
public static void citrusSelection() {
System.out.print("\nDo you want citrus fruit included? true/false: ");
}
public static void nutSelection() {
System.out.print("\nDo you want nut snack included? true/false: ");
}
public static void go() {
//OrderSystem order = new OrderSystem();
int menuSelection = 0, submenuSelection = 0;
String sizeSelection;
boolean citrus, nut;
displayMenu();
menuSelection = userInput.nextInt();
processMenuSelection(menuSelection);
submenuSelection = userInput.nextInt();
displaySizeMenu();
sizeSelection = sizeInput.nextLine();
if (menuSelection == 1) {
if (submenuSelection == 1) {
FruitSnack fruit;
//code for Fruit
switch (sizeSelection) {
case "S":
citrusSelection();
citrus = userInput.nextBoolean();
fruit = new FruitSnack("SF1", "S", citrus);
System.out.print(fruit);
break;
case "M":
citrusSelection();
citrus = userInput.nextBoolean();
fruit = new FruitSnack("MF1", "M", citrus);
System.out.print(fruit);
break;
case "L":
citrusSelection();
citrus = userInput.nextBoolean();
fruit = new FruitSnack("LF1", "L", citrus);
System.out.print(fruit);
break;
}
} else {
SaltySnack salty;
//code for Nut
switch (sizeSelection) {
case "S":
nutSelection();
nut = userInput.nextBoolean();
salty = new SaltySnack("SS1", "S", nut);
System.out.print(salty);
break;
case "M":
nutSelection();
nut = userInput.nextBoolean();
salty = new SaltySnack("MS1", "M", nut);
System.out.print(salty);
break;
case "L":
nutSelection();
nut = userInput.nextBoolean();
salty = new SaltySnack("LS1", "L", nut);
System.out.print(salty);
break;
}
}
}
}
public static void main(String[] args) {
go();
}
}