-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkstation.cpp
More file actions
100 lines (82 loc) · 2.11 KB
/
Copy pathWorkstation.cpp
File metadata and controls
100 lines (82 loc) · 2.11 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
#include <iostream>
#include <string>
#include "Workstation.h"
#include "CustomerOrder.h"
#include "Station.h"
#include "Utilities.h"
using namespace std;
namespace sdds
{
deque<CustomerOrder> pending{};
deque<CustomerOrder> completed{};
deque<CustomerOrder> incomplete{};
Workstation::Workstation(const std::string& line) : Station(line)
{
}
void Workstation::fill(std::ostream& os)
{
if (!m_orders.empty())
{
m_orders.front().fillItem(*this, os);
}
}
bool Workstation::attemptToMoveOrder()
{
if (m_orders.empty())
{
return false;
}
CustomerOrder& currentOrder = m_orders.front();
std::string item = this->getItemName();
if (currentOrder.isItemFilled(item) || getQuantity() == 0) //IF true no more service IF true Out of stock. Item is filled
{
//moving to the next station
if (m_pNextStation) //next station exists
{
*m_pNextStation += std::move(currentOrder);
m_orders.pop_front(); //remove the first order from the queue.
return true;
}
if (currentOrder.isFilled()) //nextStation doest exist and order is filled with its items
{
completed.push_back(std::move(currentOrder));
m_orders.pop_front(); //remove the first order from the queue.
return true;
}
else //Current Order is not filled and No Next Station
{
incomplete.push_back(std::move(currentOrder));
m_orders.pop_front(); //remove the first order from the queue.
return true;
}
}
return false;
}
Workstation& Workstation::operator+=(CustomerOrder&& newOrder)
{
m_orders.push_back(std::move(newOrder));
return *this;
}
void Workstation::display(std::ostream& os) const
{
//ITEM_NAME-- > NEXT_ITEM_NAME
//ITEM_NAME
os << getItemName();
if (m_pNextStation == nullptr)
{
os << " --> End of Line" << endl;
}
else
{
os << " --> " << m_pNextStation->getItemName() << endl;
}
}
void Workstation::setNextStation(Workstation* station)
{
m_pNextStation = station;
}
Workstation* Workstation::getNextStation() const
{
return m_pNextStation;
}
}