|
|
|
@ -1,10 +1,7 @@
|
|
|
|
|
#include "seller.h"
|
|
|
|
|
|
|
|
|
|
Seller::Seller() : Entity() {}
|
|
|
|
|
|
|
|
|
|
Seller::Seller(const std::string& firstName, const std::string& lastName, int sellerNo,
|
|
|
|
|
int numArticlesOffered)
|
|
|
|
|
: Entity()
|
|
|
|
|
int numArticlesOffered) : Entity()
|
|
|
|
|
{
|
|
|
|
|
firstName_ = firstName;
|
|
|
|
|
lastName_ = lastName;
|
|
|
|
@ -20,10 +17,10 @@ void Seller::setLastName(const std::string& lastName) { lastName_ = lastName; }
|
|
|
|
|
|
|
|
|
|
void Seller::setNumArticlesOffered(int number) { numArticlesOffered_ = number; }
|
|
|
|
|
|
|
|
|
|
void Seller::addArticle(std::shared_ptr<Article> article)
|
|
|
|
|
void Seller::addArticle(std::unique_ptr<Article> article)
|
|
|
|
|
{
|
|
|
|
|
article->setSeller(this);
|
|
|
|
|
articles_.push_back(article);
|
|
|
|
|
articles_.push_back(std::move(article));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string Seller::getFirstName() const { return firstName_; }
|
|
|
|
@ -35,7 +32,7 @@ int Seller::getSellerNo() const { return sellerNo_; }
|
|
|
|
|
std::vector<Article*> Seller::getArticles(bool onlySold) const
|
|
|
|
|
{
|
|
|
|
|
std::vector<Article*> articles;
|
|
|
|
|
for (const auto article : articles_) {
|
|
|
|
|
for (const auto& article : articles_) {
|
|
|
|
|
if (onlySold && article->isSold()) {
|
|
|
|
|
articles.push_back(article.get());
|
|
|
|
|
} else if (!onlySold) {
|
|
|
|
@ -52,7 +49,7 @@ int Seller::numArticlesOffered() const { return numArticlesOffered_; }
|
|
|
|
|
void Seller::cleanupArticles()
|
|
|
|
|
{
|
|
|
|
|
articles_.erase(std::remove_if(articles_.begin(), articles_.end(),
|
|
|
|
|
[](const std::shared_ptr<Article>& article) {
|
|
|
|
|
[](const auto& article) {
|
|
|
|
|
return article->getState() == Article::State::DELETE;
|
|
|
|
|
}),
|
|
|
|
|
articles_.end());
|
|
|
|
|