-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest.java
111 lines (101 loc) · 4.57 KB
/
Test.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
103
104
105
106
107
108
109
110
111
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test
{
private static int choice,choice1;
public static void main() throws NumberFormatException, IOException
{
do
{
System.out.print("========= Sundae Menu ============ \n");
System.out.print(" 1. Caramel Apple Sundae \n");
System.out.print(" 2. Strawberry Bonanza Sundae\n");
System.out.print(" 3. Chocolate Waffle Sundae \n");
System.out.print(" 4. Tropical Pineapple Sundae \n");
System.out.print(" 5. Exit \n");
System.out.print("Enter your choice: ");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
choice=Integer.parseInt(br.readLine());
if(choice<1 || choice>4)
{
System.out.println("\nThank you : ) ");
break;
}
System.out.print("\n========= Additional Sundae Toppings ============ \n");
System.out.print(" 1. Brownie bites \n");
System.out.print(" 2. Oreo\n");
System.out.print(" 3. Caramel \n");
System.out.print(" 4. Nuts \n");
System.out.print(" 5. Choco chips \n");
System.out.print(" 6. Fruits \n");
System.out.print(" 7. Sprinkles \n");
System.out.print(" 8. Exit \n");
System.out.print("Enter your choice: ");
choice1=Integer.parseInt(br.readLine());
switch (choice)
{
case 1:
{
Icecream ic=new CaramelApple();
ic.templateMethod(2);
if(choice1==1)ic=new Browniebites(ic);
else if(choice1==2)ic=new Oreo(ic);
else if(choice1==3)ic=new Caramel(ic);
else if(choice1==4)ic=new Nuts(ic);
else if(choice1==5)ic=new Chocochips(ic);
else if(choice1==6)ic=new Fruits(ic);
else if(choice1==7)ic=new Sprinkles(ic);
System.out.println("\n---Bill---");
System.out.println(ic.getName()+ " Rs. " + ic.getPrice()+"\n\n\n\n");
}
break;
case 2:
{
Icecream ic=new Strawberry();
ic.templateMethod(2);
if(choice1==1)ic=new Browniebites(ic);
else if(choice1==2)ic=new Oreo(ic);
else if(choice1==3)ic=new Caramel(ic);
else if(choice1==4)ic=new Nuts(ic);
else if(choice1==5)ic=new Chocochips(ic);
else if(choice1==6)ic=new Fruits(ic);
else if(choice1==7)ic=new Sprinkles(ic);
System.out.println("\n---Bill---");
System.out.println(ic.getName()+ " Rs. " + ic.getPrice()+"\n\n\n\n");
}
break;
case 3:
{
Icecream ic=new Chocolate();
ic.templateMethod(2);
if(choice1==1)ic=new Browniebites(ic);
else if(choice1==2)ic=new Oreo(ic);
else if(choice1==3)ic=new Caramel(ic);
else if(choice1==4)ic=new Nuts(ic);
else if(choice1==5)ic=new Chocochips(ic);
else if(choice1==6)ic=new Fruits(ic);
else if(choice1==7)ic=new Sprinkles(ic);
System.out.println("\n---Bill---");
System.out.println(ic.getName()+ " Rs. " + ic.getPrice()+"\n\n\n\n");
}
break;
case 4:
{
Icecream ic=new Pineapple();
ic.templateMethod(2);
if(choice1==1)ic=new Browniebites(ic);
else if(choice1==2)ic=new Oreo(ic);
else if(choice1==3)ic=new Caramel(ic);
else if(choice1==4)ic=new Nuts(ic);
else if(choice1==5)ic=new Chocochips(ic);
else if(choice1==6)ic=new Fruits(ic);
else if(choice1==7)ic=new Sprinkles(ic);
System.out.println("\n---Bill---");
System.out.println(ic.getName()+ " Rs. " + ic.getPrice()+"\n\n\n\n");
}
break;
}
}while(choice!=5);
}
}