-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPizzaParty.java
More file actions
59 lines (46 loc) · 1.5 KB
/
PizzaParty.java
File metadata and controls
59 lines (46 loc) · 1.5 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
import java.util.ArrayList;
import java.util.Random;
public class PizzaParty {
static int dough = 0;
static int pepperoni = 0;
static int cheese = 0;
public static void main(String[] args) {
System.out.println("Welcome to Pizza Hut!");
if (dough == 0 || pepperoni == 0 || cheese == 0) {
restock();
}
String[] menu = {"Cheese", "Pepperoni", "Meat Lovers", "Hawaiian"};
ArrayList<String> customers = new ArrayList<String>();
customers.add("Andy");
customers.add("Ezra");
customers.add("Ethan");
for (int i = customers.size() - 1; i != -1; i--) {
Random random = new Random();
int randomIndex = random.nextInt(menu.length);
String randomOrder = menu[randomIndex];
createPizza(randomOrder);
System.out.println(randomOrder + " pizza for " + customers.get(i) + "!");
}
}
public static void restock() {
dough += 10;
pepperoni += 10;
cheese += 10;
}
public static void createPizza(String pizzaType) {
switch (pizzaType) {
case "Cheese":
cheese -= 2;
dough -= 2;
break;
case "Pepperoni", "Meat Lovers", "Hawaiian":
cheese -= 2;
dough -= 2;
pepperoni -= 2;
break;
default:
System.out.println("Pizza not recognized!");
break;
}
}
}