q

Size: a a a
q
AB
AB
q
std::size_t shop::getBatchCost (const std::vector <std::pair<std::size_t, std::size_t>>& batch) const {
std::map <std::pair<size_t, std::string>, std::pair <std::size_t, std::size_t>>::const_iterator prodIt = products.begin();
std::vector <std::pair<std::size_t, std::size_t>>::const_iterator batchIt = batch.begin();
std::size_t totalSum = 0;
while (batchIt != batch.end()) {
while (prodIt != products.end()) {
if (prodIt->first.first == batchIt->first) {
if (batchIt->second > prodIt->second.first) {
throw std::runtime_error ("The amount of vegetables less than requested!");
} else {
totalSum += prodIt->second.second * batchIt->second;
}
}
prodIt++;
}
batchIt++;
}
return totalSum;
}
q
AB
q
std::size_t getProdCost (const std::size_t prodId) const;
AB
q
q
AB
q
q
AB
AB
AB
q