/
Program.cs
388 lines (265 loc) · 14.4 KB
/
Program.cs
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PizzaDeliveryProgram
{
class Program
{
static void Main(string[] args)
{
// the Bridge design pattern is used for customer/employee access interfaces/viewpoints
// the Observer design pattern is used for placing/deletsing orders and letting customers know when the order has been sent through and completed
// the Factory Method design pattern will build the customers order.
Console.WriteLine("-------------------Pizza Delivery Program/Application---------------");
string empType;
string name;
#region orderingVariables
string cusName;
string usertype;
string location;
string pizzaName;
string pizzaType;
string pizzaBase;
string topping;
string sides;
string drink;
int orderNumber = 0;
string response;
bool placed = false;
bool completeOrder = false;
#endregion
// stores customer order components
IDictionary<string, string> cusOrderSpec = new Dictionary<string, string>();
// stores inputted results
object[] orderResults = new object[9];
#region pizzaAndbranches
// locations of pizza branches
string[] PizzaBranches = new string[] { "london", "bath", "leeds", "bristol", "manchester" };
List<string> Branches = new List<string>();
Branches.AddRange(PizzaBranches);
// types of pizza that are availible
string[] PizzaTypes = new string[] { "neopoliton", "deep dish", "new york style", "greek", "sicilian", "calzone" };
List<string> typesOfPizza = new List<string>();
// adds to list
typesOfPizza.AddRange(PizzaTypes);
#endregion
TheKitchen kitchen = new TheKitchen();
Order testOrder = new Order();
char input = 'z';
#region orderingSystem
// the while loop allows for continous input without having to re run the program every time after completed orders
while (input != 'q')
{
// prompts user to say whether they are a customer or employee
Console.WriteLine("Are you a customer or employee?");
usertype = Console.ReadLine();
if (usertype == "customer" || usertype == "Customer")
{
// customer interface
UserTypes customer = new Customers();
IUsertype currentState = new CustomerView();
customer.setState(currentState);
customer.MoveToCurrentState();
orderNumber = orderNumber + 1;
orderResults[0] = orderNumber;
//asks customer for their name
Console.WriteLine("what is your name?");
cusName = Console.ReadLine();
//adds attribute to data storage
orderResults[1] = cusName;
cusOrderSpec.Add("cName", cusName);
Customer cus1 = new Customer();
//asks customer what branch they are ordering from
Console.WriteLine("which branch would you like to order from? we have branches in london, bath, leeds, bristol and manchester");
location = Console.ReadLine();
//checks if branch exists
if (Branches.Contains(location))
{
Console.WriteLine(location + " is your nearest branch");
//adds attribute to data storage
orderResults[8] = location;
cusOrderSpec.Add("loc", location);
Branch branch1 = new Branch(location);
}
else
{
// if branch does not exist
Console.WriteLine("we do not have a branch in that area");
//asks customer what branch they are ordering from
Console.WriteLine("which branch would you like to order from? we have branches in london, bath, leeds, bristol and manchester");
location = Console.ReadLine();
//checks if branch exists
if (Branches.Contains(location))
{
Console.WriteLine(location + " is your nearest branch");
//adds attribute to data storage
orderResults[8] = location;
cusOrderSpec.Add("loc", location);
Branch branch2 = new Branch(location);
}
}
//asks customer what pizza they would like
Console.WriteLine("what pizza would you like");
pizzaName = Console.ReadLine();
//adds attribute to data storage
orderResults[2] = pizzaName;
cusOrderSpec.Add("pName", pizzaName);
//asks customer what type of pizza they would like
Console.WriteLine("what type of pizza would you like? we offer neopoliton, deep dish, new york style, greek, sicilian and calzone");
pizzaType = Console.ReadLine();
if (typesOfPizza.Contains(pizzaType))
{
Console.WriteLine(pizzaType + " is selected");
//adds attribute to data storage
orderResults[3] = pizzaType;
cusOrderSpec.Add("pType", pizzaType);
Pizza p1 = new Pizza(pizzaName, pizzaType);
}
else
{
// this code runs if the user gives an input that does not exist
Console.WriteLine("pizza type is not availible");
//asks customer what type of pizza they would like
Console.WriteLine("what type of pizza would you like? we offer neopoliton, deep dish, new york style, greek, sicilian and calzone");
pizzaType = Console.ReadLine();
if (typesOfPizza.Contains(pizzaType))
{
Console.WriteLine(pizzaType + " is selected");
//adds attribute to data storage
orderResults[3] = pizzaType;
cusOrderSpec.Add("pType", pizzaType);
Pizza p1 = new Pizza(pizzaName, pizzaType);
}
}
//asks customer what topping they would like
Console.WriteLine("what topping would you like?");
topping = Console.ReadLine();
//adds attribute to data storage
orderResults[4] = topping;
cusOrderSpec.Add("topp", topping);
PizzaToppings topp1 = new PizzaToppings(topping);
Console.WriteLine("what size base would you like for your pizza");
pizzaBase = Console.ReadLine();
Base base1 = new Base(pizzaBase);
//adds attribute to data storage
orderResults[5] = pizzaBase;
cusOrderSpec.Add("base", pizzaBase);
//asks customer what side they would like
Console.WriteLine("what side would you like with your order?");
sides = Console.ReadLine();
Sides sides1 = new Sides(sides);
orderResults[6] = sides;
cusOrderSpec.Add("sName", sides);
//asks drinks what side they would like
Console.WriteLine("what drink would you like with your order?");
drink = Console.ReadLine();
//adds attribute to data storage
orderResults[7] = drink;
cusOrderSpec.Add("dName", drink);
Drinks drink1 = new Drinks(drink);
// prints summary of propsed customer order
Console.WriteLine(cusName + " , here is your proposed order");
foreach (var order in orderResults)
{
// prints customers selected order to be sent through to be processed
Console.WriteLine(order);
}
Console.WriteLine("Would you like to place your order: ");
response = Console.ReadLine();
if (response == "yes")
// places customer order
{
Customer customerObject = new Customer(cusName, location);
Order customerOrder = new Order(orderNumber, cusName, pizzaName, pizzaType, topping, pizzaBase, sides, drink, location);
cus1.placeOrder(testOrder);
// boolean value is true
placed = true;
}
// runs if customer decides to delete the order
else if (response == "no")
{
cus1.deleteOrder(testOrder);
placed = false;
// removes current order so that a new order can be made
cusOrderSpec.Remove("cName");
cusOrderSpec.Remove("loc");
cusOrderSpec.Remove("pName");
cusOrderSpec.Remove("pType");
cusOrderSpec.Remove("topp");
cusOrderSpec.Remove("base");
cusOrderSpec.Remove("sName");
cusOrderSpec.Remove("dName");
orderNumber = orderNumber = 0;
}
}
else if (usertype == "employee" || usertype == "Employee")
{
// employee interface using the bridge design pattern
UserTypes employee = new Employees();
IUsertype currentState1 = new EmployeeView();
employee.setState(currentState1);
employee.MoveToCurrentState();
// prompts employee for name
Console.WriteLine("What is your name?");
name = Console.ReadLine();
// prompts employee for job rank
Console.WriteLine("What is your job rank?");
empType = Console.ReadLine();
// accesses chef interface
if (empType == "chef")
{
Chef chef1 = new Chef(name, empType);
//cusOrderSpec.Add("emp", name);
testOrder.NotifyCurrentCustomers();
Orders finalOrder = kitchen.CreatedCustomerOrder("pizza", cusOrderSpec);
Console.WriteLine(finalOrder.ToString());
Console.ReadLine();
completeOrder = true;
}
// accesses manager interface
else if (empType == "manager")
{
Manager man1 = new Manager(name, empType);
if (completeOrder == true)
{
Console.WriteLine("the customers order has been completed");
// removes the data in the completed order so that a new order can be made
cusOrderSpec.Remove("cName");
cusOrderSpec.Remove("loc");
cusOrderSpec.Remove("pName");
cusOrderSpec.Remove("pType");
cusOrderSpec.Remove("topp");
cusOrderSpec.Remove("base");
cusOrderSpec.Remove("sName");
cusOrderSpec.Remove("dName");
}
else
{
Console.WriteLine("the customer's order has not been completed");
}
}
// team member interface
else if (empType == "team member")
{
TeamMember tm1 = new TeamMember(name, empType);
// if order was confirmed by customer
if (placed == true)
{
Console.WriteLine("Order status: Recieved");
testOrder.PlacedOrder();
testOrder.FirstUpdate();
}
else if (placed == false)
{
// if order was withdrawn by customer
Console.WriteLine("Order status: Withdrawn");
testOrder.DeletedOrder();
}
}
}
}
}
#endregion
}
}