more on sales
This commit is contained in:
parent
91357d7c7f
commit
f838977283
2 changed files with 24 additions and 4 deletions
|
@ -8,6 +8,16 @@ void Sale::addArticle(std::shared_ptr<Article> articlePtr)
|
|||
articles_.push_back(articlePtr);
|
||||
}
|
||||
|
||||
std::vector<Article*> Sale::getArticles()
|
||||
{
|
||||
std::vector<Article*> articles(articles_.size());
|
||||
for (const auto& article : articles_) {
|
||||
articles.push_back(article.get());
|
||||
}
|
||||
|
||||
return articles;
|
||||
}
|
||||
|
||||
void Sale::removeArticle(const Article* articlePtr)
|
||||
{
|
||||
auto it = std::find_if(articles_.begin(), articles_.end(),
|
||||
|
@ -23,4 +33,8 @@ int Sale::sumInCents()
|
|||
int sum = std::accumulate(articles_.begin(), articles_.end(), 0,
|
||||
[](int a, std::shared_ptr<Article> b) { return a + b->getPrice(); });
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Sale::getTimestamp() { return timestamp_; }
|
||||
|
||||
void Sale::setTimestamp(const std::string& timestamp) { timestamp_ = timestamp; }
|
Loading…
Add table
Add a link
Reference in a new issue