-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPizzaShop.java
102 lines (80 loc) · 3.18 KB
/
PizzaShop.java
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
import java.util.Scanner;
public class PizzaShop {
public static void topping(Pizza p){
System.out.println("You selected " + p.getDescription() + " as base pizza...");
Scanner sc = new Scanner(System.in);
System.out.println();
int t;
while(true){
System.out.print("Please select one or more topping(s) or finish the order: ");
System.out.println("\n1. Pepperoni \n2. Onion \n3. Bacon \n4. Sausage \n5. Choi \n6. ExtraCheese \n7. BlackOlives \n8. GreenPeppers \n9. Finish Order");
t = sc.nextInt();
if(t == 1){
p = new Pepperoni(p);
System.out.println("Ordered Item(s): " + p.getDescription() + " Cost: " + p.cost());
}
if(t == 2){
p = new Onion(p);
System.out.println("Ordered Item(s): " + p.getDescription() + " Cost: " + p.cost());
}
if(t == 3){
p = new Bacon(p);
System.out.println("Ordered Item(s): " + p.getDescription() + " Cost: " + p.cost());
}
if(t == 4){
p = new Sausage(p);
System.out.println("Ordered Item(s): " + p.getDescription() + " Cost: " + p.cost());
}
if(t == 5){
p = new Choi(p);
System.out.println("Ordered Item(s): " + p.getDescription() + " Cost: " + p.cost());
}
if(t == 6){
p = new ExtraChese(p);
System.out.println("Ordered Item(s): " + p.getDescription() + " Cost: " + p.cost());
}
if(t == 7){
p = new BlackOlives(p);
System.out.println("Ordered Item(s): " + p.getDescription() + " Cost: " + p.cost());
}
if(t == 8){
p = new GreenPeppers(p);
System.out.println("Ordered Item(s): " + p.getDescription() + " Cost: " + p.cost());
}
if(t == 9){
System.out.println(" Sir, You have successfully finished your order!");
System.out.println("Your Ordered Item(s): " + p.getDescription() + " Total Cost: " + p.cost());
break;
}
}
}
public static void main(String args[]){
System.out.print("Please select a Pizza : ");
System.out.println("\n1. Mozarella \n2. Mushroom \n3. Crudo \n4. Napoli");
int p;
Scanner sc = new Scanner(System.in);
p = sc.nextInt();
System.out.println();
switch (p){
case 1:
Pizza pizza = new Mozarella();
topping(pizza);
break;
case 2:
Pizza pizza2 = new Mushroom();
topping(pizza2);
break;
case 3:
Pizza pizza3 = new Crudo();
topping(pizza3);
break;
case 4:
Pizza pizza4 = new Napoli();
topping(pizza4);
break;
default:
System.out.println("Please select the correct option!!");
break;
}
}
}