kima2/src/core/seller.cpp

44 lines
1.4 KiB
C++
Raw Normal View History

2018-07-09 16:06:27 +02:00
#include "seller.h"
2018-07-11 11:53:46 +02:00
Seller::Seller() : Entity() {}
2018-07-09 16:06:27 +02:00
2018-07-11 11:53:46 +02:00
Seller::Seller(const std::string& firstName, const std::string& lastName, int sellerNo,
int numberOfArticles)
: Entity()
2018-07-09 16:06:27 +02:00
{
2018-07-10 12:51:03 +02:00
firstName_ = firstName;
lastName_ = lastName;
2018-07-11 11:53:46 +02:00
sellerNo_ = sellerNo;
numberOfOfferedArticles_ = numberOfArticles;
2018-07-09 16:06:27 +02:00
}
2018-07-11 15:59:38 +02:00
void Seller::setSellerNo(int seller_no) { sellerNo_ = seller_no; }
2018-07-09 16:06:27 +02:00
2018-07-11 11:53:46 +02:00
inline void Seller::setFirstName(const std::string& firstName) { firstName_ = firstName; }
inline void Seller::setLastName(const std::string& lastName) { lastName_ = lastName; }
inline void Seller::setNumberOfOfferedArticles(int number) { numberOfOfferedArticles_ = number; }
2018-07-11 15:59:38 +02:00
int Seller::getNumberOfOfferedArticles() const { return static_cast<int>(articles_.size()); }
2018-07-11 12:54:10 +02:00
2018-07-12 08:26:03 +02:00
void Seller::addArticle(std::shared_ptr<Article> article) { articles_.push_back(article); }
2018-07-11 15:59:38 +02:00
std::string Seller::getFirstName() const { return firstName_; }
std::string Seller::getLastName() const { return lastName_; }
int Seller::getSellerNo() const { return sellerNo_; }
2018-07-11 13:25:39 +02:00
2018-07-12 08:26:03 +02:00
std::vector<std::shared_ptr<Article>> Seller::getArticles(bool onlySold)
2018-07-11 13:25:39 +02:00
{
2018-07-12 08:26:03 +02:00
std::vector<std::shared_ptr<Article>> articles;
for (const auto article : articles_) {
if (onlySold && article->isSold()) {
articles.push_back(article);
2018-07-11 13:25:39 +02:00
} else if (!onlySold) {
2018-07-12 08:26:03 +02:00
articles.push_back(article);
2018-07-11 12:54:10 +02:00
}
}
2018-07-11 13:25:39 +02:00
return articles;
2018-07-11 12:54:10 +02:00
}