Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hello no copying +#include CustomerOrder.h #includeUtilities.h #include #include #include namespace sdds{ size_t CustomerOrder::m_widthField = 0u; size_t temp = 0u; CustomerOrder::CustomerOrder() { m_name = ; m_product

hello no copying

+#include "CustomerOrder.h" #include"Utilities.h" #include #include #include namespace sdds{ size_t CustomerOrder::m_widthField = 0u; size_t temp = 0u; CustomerOrder::CustomerOrder() { m_name = ""; m_product = ""; m_cntItem = 0; m_lstItem = nullptr; } CustomerOrder::CustomerOrder(const std::string str) { Utilities util; size_t next_pos = 0; bool check = false; std::vector tmpItem; m_name = util.extractToken(str, next_pos, check); m_product = util.extractToken(str, next_pos, check); while (check) { tmpItem.push_back(new Item(util.extractToken(str, next_pos, check))); } if (temp < util.getFieldWidth()) { temp = util.getFieldWidth(); } m_cntItem = static_cast(tmpItem.size()); m_lstItem = new Item * [m_cntItem]; for (size_t i = 0; i < m_cntItem; i++) { m_lstItem[i] = std::move(tmpItem[i]); } } CustomerOrder::CustomerOrder(CustomerOrder& copy) { throw "ERROR: Cannot make copies."; } CustomerOrder::CustomerOrder(CustomerOrder&& move) noexcept { *this = std::move(move); } CustomerOrder& CustomerOrder::operator=(CustomerOrder&& move) { if (this != &move) { m_name = move.m_name; m_product = move.m_product; m_cntItem = move.m_cntItem; m_lstItem = move.m_lstItem; m_widthField = move.m_widthField; move.m_name = ""; move.m_product = ""; move.m_cntItem = 0; move.m_lstItem = nullptr; move.m_widthField = 0; } return *this; } CustomerOrder::~CustomerOrder() { delete[] m_lstItem; m_lstItem = nullptr; } bool CustomerOrder::isItemFilled(const std::string& itemName) const { bool found = true; for (size_t i = 0; i < m_cntItem; i++) { if (m_lstItem[i]->m_itemName == itemName) { if (!m_lstItem[i]->m_isFilled) { return false; } } } return found; } bool CustomerOrder::isFilled() const { bool found = true; for (size_t i = 0; i < m_cntItem; i++) { if (m_lstItem[i]->m_isFilled == false) return false; } return found; } void CustomerOrder::fillItem(Station& station, std::ostream& os) { for (size_t i = 0; i < m_cntItem; i++) { if (m_lstItem[i]->m_itemName == station.getItemName()) { if (station.getQuantity() != 0) { station.updateQuantity(); m_lstItem[i]->m_serialNumber = station.getNextSerialNumber(); m_lstItem[i]->m_isFilled = true; os << (m_lstItem[i]->m_isFilled ? " Filled" : "Unfilled") << " " << m_name << ", " << m_product << " [" << m_lstItem[i]->m_itemName << "]" << std::endl; } else if (station.getQuantity() == 0) { os << " Unable to fill " << m_name << ", " << m_product << "[" << m_lstItem[i]->m_itemName << "]" << std::endl; } } } } void CustomerOrder::display(std::ostream& os) const { m_widthField = temp; os << m_name << " - " << m_product << std::endl; for (size_t i = 0; i < m_cntItem; i++) { os << std::setfill('0') << "[" << std::right << std::setw(6) << this->m_lstItem[i]->m_serialNumber << "] "; os << std::setfill(' ') << std::left << std::setw(this->m_widthField); os << this->m_lstItem[i]->m_itemName << " - "; this->m_lstItem[i]->m_isFilled ? os << "FILLED" : os << "TO BE FILLED"; os << std::endl; } }

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

Students also viewed these Programming questions

Question

=+6. How do automatic stabilizers work?

Answered: 1 week ago