-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkstation.cpp
More file actions
73 lines (59 loc) · 1.68 KB
/
Workstation.cpp
File metadata and controls
73 lines (59 loc) · 1.68 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
// Name: Phu Thong Pham
// Seneca Student ID: 106455199
// Seneca email: ptpham4@myseneca.ca
// Date of completion: Nov 28, 2020
//
// I confirm that I am the only author of this file
// and the content was created entirely by me.
#include <iostream>
#include <string>
#include "CustomerOrder.h"
#include "Station.h"
#include "Workstation.h"
using namespace std;
Workstation::Workstation(const std::string& workstationInit) : Station(workstationInit) {
m_pNextStation = nullptr;
}
void Workstation::runProcess(ostream& out) {
if (!m_orders.empty()) {
m_orders.front().fillItem(*this, out);
}
}
bool Workstation::moveOrder() {
if (!m_orders.empty()) {
if (m_orders.front().isItemFilled(getItemName())) {
*m_pNextStation += move(m_orders.front());
m_orders.pop_front();
return true;
}
}
return false;
}
void Workstation::setNextStation(Station& station) {
m_pNextStation = dynamic_cast<Workstation*>(addressof(station));
}
const Workstation* Workstation::getNextStation() const {
return m_pNextStation;
}
bool Workstation::getIfCompleted(CustomerOrder& order) {
if (!m_orders.empty()) {
if (m_orders.front().isOrderFilled()) {
order = move(m_orders.front());
m_orders.pop_front();
return true;
}
}
return false;
}
void Workstation::display(ostream& out) const {
out << getItemName() << " --> ";
if (m_pNextStation != nullptr)
out << m_pNextStation->getItemName();
else
out << "END OF LINE";
out << endl;
}
Workstation& Workstation::operator+=(CustomerOrder&& order) {
m_orders.push_back(move(order));
return *this;
}