kima2/src/core/seller.cpp

40 lines
1.1 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 11:53:46 +02:00
inline 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 12:54:10 +02:00
inline size_t Seller::getNumberOfOfferedArticles() { return articles_.size(); }
2018-07-11 13:25:39 +02:00
void Seller::addArticle(Article article) {
articles_.push_back(article);
}
std::vector<Article*> Seller::getArticles(bool onlySold)
{
std::vector<Article*> articles;
for (auto& article : articles_) {
if (onlySold && article.isSold()) {
articles.push_back(&article);
} else if (!onlySold) {
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
}