-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.cpp
More file actions
170 lines (145 loc) · 3.65 KB
/
Copy pathmenu.cpp
File metadata and controls
170 lines (145 loc) · 3.65 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
#include <iostream>
#include <string>
using namespace std;
class Menu {
protected:
float total;
float price;
public:
int h;
virtual void showMenu() = 0; // Pure virtual function to enforce implementation in derived classes
virtual float calculateBill(float quantity) = 0; // Calculate the total bill
};
class Appetizer : public Menu {
public:
Appetizer();
void showMenu();
float calculateBill(float);
};
Appetizer::Appetizer()
{
price = 5;
}
void Appetizer::showMenu()
{
cout << "\nIn Appetizer, we have:\n";
cout << "1. Buffalo wings\n";
cout << "2. Sweet and Sour Wings\n";
cout << "3. Chicken Spring Rolls\n";
}
float Appetizer:: calculateBill(float quantity)
{
total = quantity * price;
cout << "Your Bill is: $" << total << endl;
return total;
}
class Sandwiches : public Menu {
public:
Sandwiches();
void showMenu();
float calculateBill(float);
};
Sandwiches::Sandwiches()
{
price = 6;
}
void Sandwiches:: showMenu()
{
cout << "\nIn Sandwiches, we have:\n";
cout << "1. Egg Sandwich\n";
cout << "2. Chicken Sandwich\n";
cout << "3. Cheese Sandwich\n";
}
float Sandwiches::calculateBill(float quantity)
{
total = quantity * price;
cout << "Your Bill is: $" << total << endl;
return total;
}
class Continental : public Menu {
public:
Continental();
void showMenu();
float calculateBill(float);
};
Continental::Continental()
{
price = 7;
}
void Continental::showMenu()
{
cout << "\nIn Continental, we have:\n";
cout << "1. Creamy White Chicken Lasagna\n";
cout << "2. Spaghetti Pasta with Marinara Sauce\n";
cout << "3. Peri Peri Chicken\n";
}
float Continental::calculateBill(float quantity)
{
total = quantity * price;
cout << "Your Bill is: $" << total << endl;
return total;
}
class Chinese : public Menu
{
public:
Chinese();
void showMenu();
float calculateBill(float);
};
Chinese::Chinese()
{
price = 9;
}
void Chinese:: showMenu()
{
cout << "\nIn Chinese, we have:\n";
cout << "1. Egg Fried Rice\n";
cout << "2. Beef Chili Dry\n";
cout << "3. Vegetable Fried Rice\n";
}
float Chinese::calculateBill(float quantity)
{
total = quantity * price;
cout << "Your Bill is: $" << total << endl;
return total;
}
class Desserts : public Menu
{
public:
Desserts();
void showMenu();
float calculateBill(float);
};
Desserts::Desserts()
{
price = 8;
}
void Desserts:: showMenu()
{
cout << "\nIn Desserts, we have:\n";
cout << "1. Cream Caramel\n";
cout << "2. Chocolate Lava\n";
cout << "3. Fruit Trifle\n";
}
float Desserts:: calculateBill(float quantity)
{
total = quantity * price;
cout << "Your Bill is: $" << total << endl;
return total;
}
void processMenu(Menu& menu)
{
int choice;
float quantity;
menu.showMenu();
do {
cout << "Enter your choice: ";
cin >> choice;
if (choice < 1 || choice > 3) {
cout << "Invalid choice. Please choose a number between 1 and 3." << endl;
}
} while (choice < 1 || choice > 3);
cout << "How many would you like to order? ";
cin >> quantity;
menu.calculateBill(quantity);
}