diff --git a/src/core/seller.cpp b/src/core/seller.cpp index d2dc247..94fd9d4 100644 --- a/src/core/seller.cpp +++ b/src/core/seller.cpp @@ -49,4 +49,16 @@ int Seller::numArticlesSold() const { return static_cast(getArticles(true). int Seller::numArticlesOffered() const { return numArticlesOffered_; } -//int Seller::numArticlesTotal() const { return static_cast(getArticles().size()); } \ No newline at end of file +void Seller::cleanupArticles() +{ + articles_.erase(std::remove_if(begin(articles_), end(articles_), + [](const std::shared_ptr
& article) { + return article->getState() == Article::State::DELETE; + })); + + for (auto& article : articles_) { + article->setState(Article::State::OK); + } +} + +// int Seller::numArticlesTotal() const { return static_cast(getArticles().size()); } \ No newline at end of file diff --git a/src/core/seller.h b/src/core/seller.h index c5f3e4a..e334fb2 100644 --- a/src/core/seller.h +++ b/src/core/seller.h @@ -22,13 +22,14 @@ class Seller : public Entity void setLastName(const std::string& lastName); void setNumArticlesOffered(int number); void addArticle(std::shared_ptr
article); + void cleanupArticles(); std::string getFirstName() const; std::string getLastName() const; int getSellerNo() const; int numArticlesOffered() const; int numArticlesSold() const; - //int numArticlesTotal() const; + // int numArticlesTotal() const; std::vector getArticles(bool onlySold = true) const; private: