This repository has been archived by the owner on Jan 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDessertChef.cpp
158 lines (133 loc) · 5.38 KB
/
DessertChef.cpp
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
/*
Dessert Chef Implementation file
*/
#ifndef DESSERTCHEF_CPP
#define DESSERTCHEF_CPP
#include "DessertChef.h"
#include "MealProduct.h"
#include "CookingStrategy.h"
DessertChef::DessertChef(std::string name, Kitchen *kitchen) : Chef(name, kitchen)
{
this->chefType = "Dessert Course Chef";
}
void DessertChef::receiveOrder()
{
}
void DessertChef::sendOrder()
{
}
void DessertChef::sendMeal(Meal *meal)
{
headChef->receiveMeal(meal);
}
std::string DessertChef::getChefType()
{
return this->chefType;
}
void DessertChef::setHeadChef(HeadChef *headChef)
{
this->headChef = headChef;
}
void DessertChef::prepareMeal(Order_ *order)
{
if (order->getMenuChoice() == "Dessert")
{
this->changeChefState();
std::cout << "Dessert chef is preparing" << order->getMainElement() << std::endl;
// Strategies
if (order->getMainPrepStrategy() == "Grilled")
this->cookingStrategy = new Grill();
else if (order->getMainPrepStrategy() == "Fried")
this->cookingStrategy = new Fry();
else if (order->getMainPrepStrategy() == "Baked")
this->cookingStrategy = new Bake();
else if (order->getMainPrepStrategy() == "Boiled")
this->cookingStrategy = new Boil();
else if (order->getMainPrepStrategy() == "Sushi")
this->cookingStrategy = new Sushi();
else if (order->getMainPrepStrategy() == "Saute")
this->cookingStrategy = new Saute();
else if (order->getMainPrepStrategy() == "Simmered")
this->cookingStrategy = new Simmer();
else if (order->getMainPrepStrategy() == "Salad")
this->cookingStrategy = new Salad();
else if (order->getMainPrepStrategy() == "No Cook")
this->cookingStrategy = new NoCook();
else if (order->getMainPrepStrategy() == "Cold Dessert")
this->cookingStrategy = new ColdDessert();
else if (order->getMainPrepStrategy() == "Warm Dessert")
this->cookingStrategy = new HotDessert();
else
{
std::cout << "Invalid main cooking method. Cannot prepare meal." << std::endl;
return;
}
if (order->getSidePrepStrategy() == "Grilled")
this->sideStrategy = new Grill();
else if (order->getSidePrepStrategy() == "Fried")
this->sideStrategy = new Fry();
else if (order->getSidePrepStrategy() == "Baked")
this->sideStrategy = new Bake();
else if (order->getSidePrepStrategy() == "Boiled")
this->sideStrategy = new Boil();
else if (order->getSidePrepStrategy() == "Sushi")
this->sideStrategy = new Sushi();
else if (order->getSidePrepStrategy() == "Saute")
this->sideStrategy = new Saute();
else if (order->getSidePrepStrategy() == "Simmered")
this->sideStrategy = new Simmer();
else if (order->getSidePrepStrategy() == "Salad")
this->sideStrategy = new Salad();
else if (order->getSidePrepStrategy() == "No Cook")
this->sideStrategy = new NoCook();
else
{
std::cout << "No side selected." << std::endl;
this->sideStrategy = nullptr;
// return;
}
// std::cout << order->getMainPrepStrategy() <<" is prep strat " << order->getMenuChoice()<< std::endl;
// Builder
MealBuilder *mealBuilder = new MealBuilder();
mealBuilder->setMealType(order->getMenuChoice()); // Set Meal Type
mealBuilder->setMainElement(order->getMainElement()); // Set Main Element
mealBuilder->setMainElementPrepStrategy(cookingStrategy->cookMeal(order->getMainPrepStrategy())); // Set Main Cook Strat
mealBuilder->setSideChoice(order->getSidesElement()); // Set Side Choice
mealBuilder->setSideElement(order->getSidesElement());
mealBuilder->setTableNO(order->tableNO);
if (this->sideStrategy != nullptr)
{ // Set Side Element
mealBuilder->setSideElementPrepStrategy(sideStrategy->cookMeal(order->getSidePrepStrategy())); // Set Side Cook Strat
}
else
mealBuilder->setSideElementPrepStrategy("No side");
mealBuilder->setSauceChoice(order->getSauceElement()); // Set Sauce Choice
mealBuilder->setSauceElement(order->getSauceElement()); // Set Sauce Element
Meal *meal = mealBuilder->getMeal(); // Return Meal
// set the table no.
// meal->printMeal();
// std::cout << "\n\nmain el" << meal->getMainElement() << "--";
// std::cout << "\nside element " << meal->getSidesElement() << "---";
// std::cout << "\nmainprep strate " << meal->getMainPrepStrategy() << "---";
// std::cout << "\nsauce el " << meal->getSauceElement() << "---";
// std::cout << "\nmeal type " << meal->getMealType() << "---";
sendMeal(meal);
}
else
{
std::cout << this->getChefType() << " passing this order on" << std::endl;
nextChef->prepareMeal(order);
}
}
void DessertChef::setNextChef(Chef *nextChef)
{
this->nextChef = nextChef;
}
Chef *DessertChef::getNextChef()
{
return nextChef;
}
void DessertChef::receiveNotification(Staff *senderChef)
{
}
#endif