-
Notifications
You must be signed in to change notification settings - Fork 0
/
MaitreD.cpp
57 lines (46 loc) · 1.43 KB
/
MaitreD.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
#include "MaitreD.h"
#include "ThreadSleep.h"
MaitreD * MaitreD::maitreD = nullptr;
MaitreD * MaitreD::instance()
{
if(maitreD == nullptr)
{
maitreD = new MaitreD();
}
return maitreD;
}
Table* MaitreD::seatCustomers(Restaurant& list, std::vector<Customer*> vect)
{
std::cout<<"MaitreD assigns customers to a table..."<<std::endl;
Table* table= list.addCustomer(vect);
ThreadSleep::threadSleep();
if (!table->getTableType()){
std::cout << "Customers on table "<<to_string(table->getTableNumber())<<" are seated...\n";
return table;
}
return NULL;
}
MaitreD::~MaitreD()
{
if(maitreD != nullptr)
{
delete maitreD;
}
maitreD = nullptr;
}
void MaitreD::checkingOnTable(Restaurant * restaurant){
TableIterator* tableIterator= restaurant->createIterator();
while(tableIterator->hasNext()){
cout<<"MaitreD currently on table "<<tableIterator->current()->getTableNumber()<<"...\n";
if (tableIterator->current()->getState()->toString()!="Empty Table"){
tableIterator->current()->IsEverythingOkay(tableIterator->current()->getWaiter());
cout<<endl;
}
else{
cout<<"Table "<<tableIterator->current()->getTableNumber()<<" is currently empty...\n\n";
}
tableIterator->next();
}
delete tableIterator;
}
MaitreD::MaitreD(){}