Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am getting this error Checking output: In line number 123 of your output: The output should be: Filled Chris S., Bedroom [Bed] ^ But

I am getting this error Checking output: In line number 123 of your output: The output should be: Filled Chris S., Bedroom [Bed] ^ But your output is: Filled Chris S. , Bedroom [Bed] ^

Unmatched character details: The character in column 20 is supposed to be: [,] ASCII code(44) but you printed [Space] ASCII code(32)

sample output should be like this nedd help urgent

Command Line: ./ms3 Stations1.txt Stations2.txt CustomerOrders.txt AssemblyLine.txt

======================================== = Stations (summary) = ======================================== 001 | Armchair | 654321 | 002 | Bed | 123456 | 003 | Dresser | 056789 | 004 | Nighttable | 000887 | 005 | Filing Cabinet | 987654 | 006 | Office Chair | 147852 | 007 | Bookcase | 000987 | 008 | Desk | 459214 |

======================================== = Stations (full) = ======================================== 001 | Armchair | 654321 | 10 | Upholstered Wing Chair 002 | Bed | 123456 | 5 | Queen size bed with headboard 003 | Dresser | 056789 | 7 | 6-Drawer Unit 004 | Nighttable | 000887 | 5 | Nightstand with 2 drawers 005 | Filing Cabinet | 987654 | 5 | 3-drawer filing cabinet 006 | Office Chair | 147852 | 20 | High-back carpet-rollers 007 | Bookcase | 000987 | 5 | 5-shelf open bookcase 008 | Desk | 459214 | 2 | 6-foot worktable

======================================== = Manual Validation = ======================================== getItemName(): Armchair getNextSerialNumber(): 654321 getNextSerialNumber(): 654322 getQuantity(): 10 getQuantity(): 9

======================================== = Orders = ======================================== Cornel B. - 1-Room Home Office [000000] Office Chair - TO BE FILLED [000000] Desk - TO BE FILLED [000000] Bookcase - TO BE FILLED [000000] Bookcase - TO BE FILLED [000000] Filing Cabinet - TO BE FILLED Chris S. - Bedroom [000000] Bed - TO BE FILLED [000000] Armchair - TO BE FILLED [000000] Nighttable - TO BE FILLED [000000] Dresser - TO BE FILLED [000000] Nighttable - TO BE FILLED John M. - Kids Bedroom [000000] Bed - TO BE FILLED [000000] Bed - TO BE FILLED [000000] Bed - TO BE FILLED [000000] Bed - TO BE FILLED [000000] Nighttable - TO BE FILLED [000000] Nighttable - TO BE FILLED [000000] Dresser - TO BE FILLED [000000] Desk - TO BE FILLED Hong H. - 1-Room Office [000000] Desk - TO BE FILLED [000000] Office Chair - TO BE FILLED [000000] Office Chair - TO BE FILLED [000000] Filing Cabinet - TO BE FILLED [000000] Filing Cabinet - TO BE FILLED [000000] Filing Cabinet - TO BE FILLED [000000] Bookcase - TO BE FILLED Rania A. - 2-Room Home Office and Bedroom [000000] Desk - TO BE FILLED [000000] Desk - TO BE FILLED [000000] Office Chair - TO BE FILLED [000000] Bed - TO BE FILLED [000000] Office Chair - TO BE FILLED [000000] Office Chair - TO BE FILLED [000000] Nighttable - TO BE FILLED [000000] Armchair - TO BE FILLED [000000] Dresser - TO BE FILLED

======================================== = Display Stations (loaded) = ======================================== Nighttable --> Desk Dresser --> Armchair Filing Cabinet --> Bookcase Bookcase --> End of Line Bed --> Dresser Office Chair --> Filing Cabinet Armchair --> Nighttable Desk --> Office Chair

======================================== = Display Stations (ordered) = ======================================== Bed --> Dresser Dresser --> Armchair Armchair --> Nighttable Nighttable --> Desk Desk --> Office Chair Office Chair --> Filing Cabinet Filing Cabinet --> Bookcase Bookcase --> End of Line

======================================== = Filling Orders = ======================================== Line Manager Iteration: 1 Line Manager Iteration: 2 Filled Chris S., Bedroom [Bed] Filled Cornel B., 1-Room Home Office [Desk] Line Manager Iteration: 3 Filled John M., Kids Bedroom [Bed] Filled Chris S., Bedroom [Dresser] Filled Cornel B., 1-Room Home Office [Office Chair] Line Manager Iteration: 4 Filled John M., Kids Bedroom [Bed] Filled Chris S., Bedroom [Armchair] Filled Cornel B., 1-Room Home Office [Filing Cabinet] Line Manager Iteration: 5 Filled John M., Kids Bedroom [Bed] Filled Chris S., Bedroom [Nighttable] Filled Cornel B., 1-Room Home Office [Bookcase] Line Manager Iteration: 6 Filled John M., Kids Bedroom [Bed] Filled Chris S., Bedroom [Nighttable] Filled Cornel B., 1-Room Home Office [Bookcase] Line Manager Iteration: 7 Filled John M., Kids Bedroom [Dresser] Line Manager Iteration: 8 Unable to fill Rania A., 2-Room Home Office and Bedroom [Bed] Filled John M., Kids Bedroom [Nighttable] Line Manager Iteration: 9 Filled Rania A., 2-Room Home Office and Bedroom [Dresser] Filled John M., Kids Bedroom [Nighttable] Line Manager Iteration: 10 Filled Rania A., 2-Room Home Office and Bedroom [Armchair] Filled John M., Kids Bedroom [Desk] Line Manager Iteration: 11 Filled Rania A., 2-Room Home Office and Bedroom [Nighttable] Unable to fill Hong H., 1-Room Office [Desk] Line Manager Iteration: 12 Unable to fill Rania A., 2-Room Home Office and Bedroom [Desk] Unable to fill Rania A., 2-Room Home Office and Bedroom [Desk] Filled Hong H., 1-Room Office [Office Chair] Line Manager Iteration: 13 Filled Hong H., 1-Room Office [Office Chair] Line Manager Iteration: 14 Filled Rania A., 2-Room Home Office and Bedroom [Office Chair] Filled Hong H., 1-Room Office [Filing Cabinet] Line Manager Iteration: 15 Filled Rania A., 2-Room Home Office and Bedroom [Office Chair] Filled Hong H., 1-Room Office [Filing Cabinet] Line Manager Iteration: 16 Filled Rania A., 2-Room Home Office and Bedroom [Office Chair] Filled Hong H., 1-Room Office [Filing Cabinet] Line Manager Iteration: 17 Filled Hong H., 1-Room Office [Bookcase] Line Manager Iteration: 18

======================================== = Processed Orders (complete) = ======================================== Cornel B. - 1-Room Home Office [147852] Office Chair - FILLED [459214] Desk - FILLED [000987] Bookcase - FILLED [000988] Bookcase - FILLED [987654] Filing Cabinet - FILLED Chris S. - Bedroom [123456] Bed - FILLED [654323] Armchair - FILLED [000887] Nighttable - FILLED [056789] Dresser - FILLED [000888] Nighttable - FILLED John M. - Kids Bedroom [123457] Bed - FILLED [123458] Bed - FILLED [123459] Bed - FILLED [123460] Bed - FILLED [000889] Nighttable - FILLED [000890] Nighttable - FILLED [056790] Dresser - FILLED [459215] Desk - FILLED

======================================== = Processed Orders (incomplete) = ======================================== Hong H. - 1-Room Office [000000] Desk - TO BE FILLED [147853] Office Chair - FILLED [147854] Office Chair - FILLED [987655] Filing Cabinet - FILLED [987656] Filing Cabinet - FILLED [987657] Filing Cabinet - FILLED [000989] Bookcase - FILLED Rania A. - 2-Room Home Office and Bedroom [000000] Desk - TO BE FILLED [000000] Desk - TO BE FILLED [147855] Office Chair - FILLED [000000] Bed - TO BE FILLED [147856] Office Chair - FILLED [147857] Office Chair - FILLED [000891] Nighttable - FILLED [654324] Armchair - FILLED [056791] Dresser - FILLED

======================================== = Inventory (full) = ======================================== 001 | Armchair | 654325 | 7 | Upholstered Wing Chair 002 | Bed | 123461 | 0 | Queen size bed with headboard 003 | Dresser | 056792 | 4 | 6-Drawer Unit 004 | Nighttable | 000892 | 0 | Nightstand with 2 drawers 005 | Filing Cabinet | 987658 | 1 | 3-drawer filing cabinet 006 | Office Chair | 147858 | 14 | High-back carpet-rollers 007 | Bookcase | 000990 | 2 | 5-shelf open bookcase 008 | Desk | 459216 | 0 | 6-foot worktable

CustomerOrder.cpp

 #include  #include  #include  #include  #include "CustomerOrder.h" #include "Utilities.h" namespace sdds { size_t CustomerOrder::m_widthField = 0; CustomerOrder::CustomerOrder() { m_name = {}; m_product = {}; m_cntItem = {}; m_lstItem = {}; } CustomerOrder::CustomerOrder(const std::string& str) : CustomerOrder() { Utilities utility; size_t npos{}; bool more{true}; m_name = utility.extractToken(str, npos, more); m_product = utility.extractToken(str, npos, more); m_cntItem = count(str.begin(), str.end(), Utilities::getDelimiter()) - 1; std::vector itemsList; do { itemsList.push_back(new Item(utility.extractToken(str, npos, more))); } while (more); m_lstItem = new Item*[m_cntItem]; size_t i{}; //Index for the loop; std::for_each(itemsList.begin(), itemsList.end(), [&](Item* item){ m_lstItem[i] = item; i++; }); m_widthField = std::max(utility.getFieldWidth(), m_widthField); } CustomerOrder::CustomerOrder(CustomerOrder&& src) noexcept : CustomerOrder() { *this = std::move(src); } CustomerOrder& CustomerOrder::operator=(CustomerOrder&& src) noexcept { if (this != &src) { for (size_t i = 0; i < m_cntItem; i++) delete m_lstItem[i]; delete[] m_lstItem; m_lstItem = src.m_lstItem; m_name = src.m_name; m_product = src.m_product; m_cntItem = src.m_cntItem; src.m_lstItem = nullptr; src.m_name = ""; src.m_product = ""; src.m_cntItem = 0; } return *this; } CustomerOrder::~CustomerOrder() { delete[] m_lstItem; } bool CustomerOrder::isOrderFilled() const { // bool isFilled = true; // for (size_t i = 0; i < m_cntItem && isFilled; i++ ) // isFilled = m_lstItem[i]->m_isFilled; // // return isFilled; /** Doesn't give proper output for some reason even though, logically, it is the same as the manual loop above. */ return std::all_of(m_lstItem, (m_lstItem+m_cntItem), [](const Item* item){ return item->m_isFilled; }); } bool CustomerOrder::isItemFilled(const std::string& itemName) const { // bool isItemFilled = true; // for (size_t i = 0; i < m_cntItem && isItemFilled; i++) // if (m_lstItem[i]->m_itemName == itemName) isItemFilled = m_lstItem[i]->m_isFilled; // // return isItemFilled; /** Doesn't give proper output for some reason even though, logically, it is the same as the manual loop above. */ return std::all_of(m_lstItem, m_lstItem+m_cntItem, [&itemName](Item* it){ if (it->m_itemName == itemName) return (it->m_isFilled); return true; }); } void CustomerOrder::fillItem(Station& station, std::ostream& os) { bool flag=true; std::for_each(m_lstItem, m_lstItem+m_cntItem, [&](Item* item){ //std::cout<m_itemName <<"- "; if (station.getItemName() == item->m_itemName && flag && item->m_isFilled == false ) { if (station.getQuantity() > 0 ) { station.updateQuantity(); item->m_serialNumber = station.getNextSerialNumber(); item->m_isFilled = true; os << " Filled " << m_name << ", " << m_product << " [" << item->m_itemName << "]" << std::endl; flag = false; } else { os << " Unable to fill " << m_name << ", " << m_product << " [" << item->m_itemName << "]" << std::endl; } } }); } void CustomerOrder::display(std::ostream& os) const { os << m_name << " - " << m_product << ' '; std::for_each(m_lstItem, m_lstItem + m_cntItem, [&](Item* item){ os << "[" << std::setw(6) << std::setfill('0') << item->m_serialNumber << "] " << std::setfill(' ')<< std::setw(CustomerOrder::m_widthField) << setiosflags(std::ios::left) << item->m_itemName << resetiosflags(std::ios::left)<< " - "; if (item->m_isFilled) os << "FILLED"; else os << "TO BE FILLED"; os << std::endl; }); } }

CustomerOrder.h

 #ifndef SDDS_CUSTOMERORDER_H #define SDDS_CUSTOMERORDER_H #include  #include "Station.h" namespace sdds { struct Item { std::string m_itemName; size_t m_serialNumber{0}; bool m_isFilled{false}; Item(const std::string& src) : m_itemName(src) {}; }; class CustomerOrder { std::string m_name; std::string m_product; size_t m_cntItem; Item **m_lstItem; static size_t m_widthField; public: CustomerOrder(); CustomerOrder(const std::string& str); CustomerOrder(const CustomerOrder&){ throw "Copying Disabled"; }; CustomerOrder& operator=(const CustomerOrder&) = delete; CustomerOrder(CustomerOrder&& src) noexcept; CustomerOrder& operator=(CustomerOrder&& src) noexcept; virtual ~CustomerOrder(); bool isOrderFilled() const; bool isItemFilled(const std::string& itemName) const; void fillItem(Station& station, std::ostream& os); void display(std::ostream& os) const; }; } #endif //SDDS_CUSTOMERORDER_H 

LineManager.cpp

 #include  #include  #include "Utilities.h" #include "LineManager.h" namespace sdds { LineManager::LineManager(const std::string& file, const std::vector& stations) { std::ifstream file_(file); if (!file_) throw "Failed to open the file"; else { Utilities utils; bool more; size_t npos = 0; std::string fileLine, currWSname, nxtWSname; Workstation* nxtWS = nullptr; Workstation* currWS = nullptr; Workstation* firstWS = nullptr; while (std::getline(file_, fileLine)) { currWSname = utils.extractToken(fileLine, npos, more); currWS = *std::find_if(stations.begin(), stations.end(), [&](Workstation* ws) { return ws->getItemName() == currWSname; }); m_activeLine.push_back(currWS); if (more) { nxtWSname = utils.extractToken(fileLine, npos, more); nxtWS = *std::find_if(stations.begin(), stations.end(), [&](Workstation* ws) { return ws->getItemName() == nxtWSname; }); currWS->setNextStation(nxtWS); } } for_each(stations.begin(), stations.end(), [&](Workstation* tmp) { firstWS = *find_if(stations.begin(), stations.end(), [&](Workstation* station) { return station->getNextStation() == firstWS; }); }); m_firstStation = firstWS; } file_.close(); m_cntCustomerOrder = g_pending.size(); } void LineManager::reorderStations() { const Workstation* ws = m_firstStation; size_t i{0}; do { m_activeLine[i++] = const_cast(ws); ws = ws->getNextStation(); } while (ws != nullptr); } bool LineManager::run(std::ostream& os){ static size_t iterations = 0; os << "Line Manager Iteration: " << ++iterations << std::endl; if (!g_pending.empty()) { *m_firstStation += std::move(g_pending.front()); g_pending.pop_front(); } std::for_each(m_activeLine.begin(),m_activeLine.end(), [&os](Workstation* ws){ ws->fill(os); }); std::for_each(m_activeLine.begin(),m_activeLine.end(), [](Workstation* ws){ ws->attemptToMoveOrder(); }); return m_cntCustomerOrder == (g_completed.size() + g_incomplete.size()); } void LineManager::display(std::ostream& os) const { if (!m_activeLine.empty()) for (auto& i : m_activeLine) i->display(os); } }

LineManager.h

 #ifndef SDDS_LINEMANAGER_H #define SDDS_LINEMANAGER_H #include  #include "Workstation.h" namespace sdds { class LineManager { std::vector m_activeLine; size_t m_cntCustomerOrder; Workstation* m_firstStation; public: LineManager(const std::string& ws, const std::vector& stations); void reorderStations(); bool run(std::ostream& os); void display(std::ostream& os) const; }; } #endif //SDDS_LINEMANAGER_H

Station.cpp

 #include  #include  #include "Utilities.h" #include "Station.h" namespace sdds { size_t Station::m_widthField = 0; size_t Station::id_generator = 1; const std::string WHITESPACE = " \t\f\v"; std::string rtrim(const std::string &s) { size_t end = s.find_last_not_of(" "); return (end == std::string::npos) ? "" : s.substr(0, end + 1); } Station::Station(const std::string& record) { m_id = id_generator++; Utilities utils; size_t npos = 0; bool more; try { m_name = utils.extractToken(record, npos, more); m_name=rtrim(rtrim(m_name)); m_nextSerial = std::stoi(utils.extractToken(record, npos, more)); m_stockQty = std::stoi(utils.extractToken(record, npos, more)); m_widthField = std::max(utils.getFieldWidth(), m_widthField); m_desc = utils.extractToken(record, npos, more); } catch (std::string& err) { std::cout << err; } } const std::string& Station::getItemName() const { return m_name; } size_t Station::getNextSerialNumber() { return m_nextSerial++; } size_t Station::getQuantity() const { return m_stockQty; } void Station::updateQuantity() { if (0 > --m_stockQty) m_stockQty = 0; } void Station::display(std::ostream& os, bool full) const { os << std::setfill('0') << std::setw(3) << std::right << m_id; os << " | " << std::setw(m_widthField) << std::setfill(' ') << std::left << m_name; os << " | " << std::setfill('0') << std::setw(6) << std::right << m_nextSerial << " | " ; if (full) { //std::setw(m_widthField) << std::setfill(' ') os << std::right << std::setw(4) << std::setfill(' ') << m_stockQty << " | "; os << std::left << m_desc << std::endl; } else os << std::endl; } } 

Station.h

 #ifndef SDDS_STATION_H #define SDDS_STATION_H #include  namespace sdds { class Station { int m_id; std::string m_name; std::string m_desc; int m_nextSerial; int m_stockQty; static size_t m_widthField; static size_t id_generator; public: Station(const std::string& record); const std::string& getItemName() const; size_t getNextSerialNumber(); size_t getQuantity() const; void updateQuantity(); void display(std::ostream& os, bool full) const; }; } #endif //SDDS_STATION_H 

Utilities.cpp

 #include "Utilities.h" #include  namespace sdds { const std::string WHITESPACE = " \t\f\v"; std::string ltrim(const std::string &s) { size_t start = s.find_first_not_of(WHITESPACE); return (start == std::string::npos) ? "" : s.substr(start); } char Utilities::m_delimiter{}; void Utilities::setFieldWidth(size_t newWidth) { m_widthField = newWidth; } size_t Utilities::getFieldWidth() const { return m_widthField; } std::string Utilities::extractToken(const std::string& str, size_t& next_pos, bool& more) { //std::cout<<"n:"<

Utilities.h

 #ifndef SDDS_UTILITIES_H #define SDDS_UTILITIES_H #include  namespace sdds { class Utilities { size_t m_widthField = 1; static char m_delimiter; public: void setFieldWidth(size_t newWidth); size_t getFieldWidth() const; std::string extractToken(const std::string& str, size_t& next_pos, bool& more); static void setDelimiter(char newDelimiter); static char getDelimiter(); }; } #endif //SDDS_UTILITIES_H 

Workstation.cpp

 #include  #include "Workstation.h" namespace sdds { std::deque g_pending {}; std::deque g_completed {}; std::deque g_incomplete {}; Workstation::Workstation(const std::string& str) : Station(str) {} void Workstation::fill(std::ostream& os) { if (!m_orders.empty()) m_orders.front().fillItem(*this, os); } bool Workstation::attemptToMoveOrder() { bool isMoved = false; if (!m_orders.empty()) { if (m_orders.front().isItemFilled(getItemName())) { if (!m_pNextStation) { if (m_orders.front().isOrderFilled()) g_completed.push_back(std::move(m_orders.front())); else g_incomplete.push_back(std::move(m_orders.front())); } else *m_pNextStation += std::move(m_orders.front()); m_orders.pop_front(); isMoved = true; } else if (!getQuantity()) { if (!m_pNextStation) g_incomplete.push_back(std::move(m_orders.front())); else *m_pNextStation += std::move(m_orders.front()); m_orders.pop_front(); isMoved = true; } } return isMoved; } void Workstation::setNextStation(Workstation *station) { if (m_pNextStation != nullptr) delete m_pNextStation; m_pNextStation = station; } Workstation *Workstation::getNextStation() const { return m_pNextStation; } void Workstation::display(std::ostream& os) const { os << getItemName() << " --> " << (m_pNextStation == nullptr ? "End of Line" : m_pNextStation->getItemName()) << ' '; } Workstation& Workstation::operator+=(CustomerOrder&& newOrder) { m_orders.push_back(std::move(newOrder)); return *this; } }

Workstation.h

 #ifndef SDDS_WORKSTATION_H #define SDDS_WORKSTATION_H #include  #include "Station.h" #include "CustomerOrder.h" namespace sdds { extern std::deque g_pending ; extern std::deque g_completed ; extern std::deque g_incomplete ; class Workstation : public Station{ std::deque m_orders {}; Workstation* m_pNextStation {}; public: Workstation(const std::string& str); void fill(std::ostream& os); bool attemptToMoveOrder(); void setNextStation(Workstation* station = nullptr); Workstation* getNextStation() const; void display(std::ostream& os) const; Workstation& operator+=(CustomerOrder&& newOrder); Workstation(const Workstation& cpyFrom) = delete; //Copy Constructor Workstation& operator=(const Workstation& cpyFrom) = delete; //Copy Assignment Operator Workstation(Workstation&& mvFrom) = delete; //Move Constructor (*this = std::move(cpyFrom);) Workstation& operator=(Workstation&& mvFrom) = delete; //Move Assignment Operator }; } #endif //SDDS_WORKSTATION_H

Step-by-step explanation

main.cpp

// Final Project // Milestone 3 // ms3_prof.cpp // Winter 2021 // Chris Szalwinski #include  #include  #include  #include  #include "Station.h" #include "Station.h" #include "Workstation.h" #include "Workstation.h" #include "CustomerOrder.h" #include "CustomerOrder.h" #include "Utilities.h" #include "Utilities.h" #include "LineManager.h" #include "LineManager.h" using namespace std; using namespace sdds; template static void loadFromFile(const char*, vector&); template static void loadFromFile(const char*, vector&); int main(int argc, char** argv) { cout << "Command Line: " << argv[0]; for (int i = 1; i < argc; i++) cout << " " << argv[i]; cout << endl << endl; if (argc != 5) { cerr << "ERROR: Incorrect number of arguments "; return 1; } vector theStations; vector theOrders; try { Utilities::setDelimiter(','); loadFromFile(argv[1], theStations); Utilities::setDelimiter('|'); loadFromFile(argv[2], theStations); cout << "========================================" << endl; cout << "= Stations (summary) =" << endl; cout << "========================================" << endl; for (const auto* station : theStations) station->Station::display(cout, false); cout << endl << endl; cout << "========================================" << endl; cout << "= Stations (full) =" << endl; cout << "========================================" << endl; for (const auto* station : theStations) station->Station::display(cout, true); cout << endl << endl; //Select an object and verify all the functionality it working cout << "========================================" << endl; cout << "= Manual Validation =" << endl; cout << "========================================" << endl; cout << "getItemName(): " << theStations[0]->getItemName() << endl; cout << "getNextSerialNumber(): " << theStations[0]->getNextSerialNumber() << endl; cout << "getNextSerialNumber(): " << theStations[0]->getNextSerialNumber() << endl; cout << "getQuantity(): " << theStations[0]->getQuantity() << endl; theStations[0]->updateQuantity(); cout << "getQuantity(): " << theStations[0]->getQuantity() << endl; cout << endl << endl; loadFromFile(argv[3], theOrders); cout << "========================================" << endl; cout << "= Orders =" << endl; cout << "========================================" << endl; for (auto& order : theOrders) { order.display(std::cout); g_pending.push_back(std::move(order)); } cout << endl << endl; cout << "========================================" << endl; cout << "= Display Stations (loaded) =" << endl; cout << "========================================" << endl; LineManager lm(argv[4], theStations); lm.display(cout); cout << endl << endl; cout << "========================================" << endl; cout << "= Display Stations (ordered) =" << endl; cout << "========================================" << endl; lm.reorderStations(); lm.display(cout); cout << endl << endl; cout << "========================================" << endl; cout << "= Filling Orders =" << endl; cout << "========================================" << endl; //run the assembly line until all orders processed while (!lm.run(cout)); cout << endl << endl; } catch (const string& msg) { cerr << msg << ' '; return 2; } cout << "========================================" << endl; cout << "= Processed Orders (complete) =" << endl; cout << "========================================" << endl; for (const auto& o : g_completed) o.display(cout); cout << endl << endl; cout << "========================================" << endl; cout << "= Processed Orders (incomplete) =" << endl; cout << "========================================" << endl; for (const auto& o : g_incomplete) o.display(cout); cout << endl << endl; cout << "========================================" << endl; cout << "= Inventory (full) =" << endl; cout << "========================================" << endl; for (const Station* theItem : theStations) theItem->display(cout, true); cout << endl; // cleanup for (auto station : theStations) delete station; return 0; } template static void loadFromFile(const char* filename, vector& theCollection) { if (!filename) { throw string("ERROR: No filename provided."); } ifstream file(filename); if (!file) throw string("Unable to open [") + filename + "] file."; string record; while (!file.eof()) { std::getline(file, record); T elem(record); theCollection.push_back(std::move(elem)); } file.close(); } template static void loadFromFile(const char* filename, vector& theCollection) { if (!filename) { throw string("ERROR: No filename provided."); } ifstream file(filename); if (!file) throw string("Unable to open [") + filename + "] file."; string record; while (!file.eof()) { std::getline(file, record); theCollection.push_back(new T(record)); } file.close(); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions