-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOrderManager.cpp
43 lines (37 loc) · 1.09 KB
/
OrderManager.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
//Sina Lahsaee
//129948162
//File includes
#include "OrderManager.h"
#include "ItemManager.h"
#include "CustomerOrder.h"
//include libraries
#include <algorithm>
using namespace std;
CustomerOrder && OrderManager::extract()
{
CustomerOrder temp = move(this->back()); //moves customer order from the back of the STL container
return move(temp); //returns the moved order that we stored inside temp.
}
void OrderManager::validate(const ItemManager &itemManager, std::ostream &os)
{
vector<CustomerOrder>::const_iterator counter;
int cnt = 0;
for (counter = begin(); counter != end(); counter++)
{
for (cnt = 0; cnt < counter->noOrders(); cnt++)
{
auto request = [&](const Item& temp) //lambda function that returns a reference to Item
{
return temp.getName() == (*counter)[cnt];
};
if (find_if(itemManager.begin(), itemManager.cend(), request) == itemManager.cend())
{
os << (*counter)[cnt] << " is unavailable" << endl;
}
}
}
}
void OrderManager::display(std::ostream &os) const //outputs description of customer order
{
for (auto& temp : *this) temp.display(os);
}