#include "seller.h" Seller::Seller() : Entity() {} Seller::Seller(const std::string& firstName, const std::string& lastName, int sellerNo, int numArticlesOffered) : Entity() { firstName_ = firstName; lastName_ = lastName; sellerNo_ = sellerNo; numArticlesOffered_ = numArticlesOffered; } void Seller::setSellerNo(int seller_no) { sellerNo_ = seller_no; } inline void Seller::setFirstName(const std::string& firstName) { firstName_ = firstName; } inline void Seller::setLastName(const std::string& lastName) { lastName_ = lastName; } inline void Seller::setNumArticlesOffered(int number) { numArticlesOffered_ = number; } void Seller::addArticle(std::shared_ptr
article) { article->setSeller(this); articles_.push_back(article); } std::string Seller::getFirstName() const { return firstName_; } std::string Seller::getLastName() const { return lastName_; } int Seller::getSellerNo() const { return sellerNo_; } std::vector Seller::getArticles(bool onlySold) const { std::vector articles; for (const auto article : articles_) { if (onlySold && article->isSold()) { articles.push_back(article.get()); } else if (!onlySold) { articles.push_back(article.get()); } } return articles; } int Seller::numArticlesSold() const { return static_cast(getArticles(true).size()); } int Seller::numArticlesOffered() const { return numArticlesOffered_; } 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()); }