Compare commits
2 commits
2131f12237
...
7c40ea6f97
Author | SHA1 | Date | |
---|---|---|---|
7c40ea6f97 | |||
d64606c861 |
4 changed files with 17 additions and 10 deletions
|
@ -10,8 +10,10 @@ void Article::setPrice(int price) { price_ = price; }
|
||||||
|
|
||||||
void Article::setDescription(const std::string& description) { description_ = description; }
|
void Article::setDescription(const std::string& description) { description_ = description; }
|
||||||
|
|
||||||
std::string Article::getDescription() { return description_; }
|
|
||||||
|
|
||||||
void Article::setSale(std::shared_ptr<Sale> salePtr) { salePtr_ = salePtr; }
|
void Article::setSale(std::shared_ptr<Sale> salePtr) { salePtr_ = salePtr; }
|
||||||
|
|
||||||
bool Article::isSold() { return salePtr_ ? true : false; }
|
bool Article::isSold() { return salePtr_ ? true : false; }
|
||||||
|
|
||||||
|
std::string Article::getDescription() { return description_; }
|
||||||
|
|
||||||
|
Seller* Article::getSeller() { return sellerPtr_.get(); }
|
|
@ -18,11 +18,13 @@ class Article : public Entity
|
||||||
void setArticleNo(int articleNo);
|
void setArticleNo(int articleNo);
|
||||||
void setPrice(int price);
|
void setPrice(int price);
|
||||||
void setDescription(const std::string& description);
|
void setDescription(const std::string& description);
|
||||||
std::string getDescription();
|
|
||||||
bool isSold();
|
bool isSold();
|
||||||
void setSale(std::shared_ptr<Sale> salePtr);
|
void setSale(std::shared_ptr<Sale> salePtr);
|
||||||
void setSeller(std::shared_ptr<Seller> sellerPtr);
|
void setSeller(std::shared_ptr<Seller> sellerPtr);
|
||||||
|
|
||||||
|
std::string getDescription();
|
||||||
|
Seller* getSeller();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Seller> sellerPtr_{};
|
std::shared_ptr<Seller> sellerPtr_{};
|
||||||
std::shared_ptr<Sale> salePtr_{};
|
std::shared_ptr<Sale> salePtr_{};
|
||||||
|
|
|
@ -30,15 +30,17 @@ std::string Seller::getLastName() const { return lastName_; }
|
||||||
|
|
||||||
int Seller::getSellerNo() const { return sellerNo_; }
|
int Seller::getSellerNo() const { return sellerNo_; }
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Article>> Seller::getArticles(bool onlySold)
|
std::vector<Article*> Seller::getArticles(bool onlySold) const
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<Article>> articles;
|
std::vector<Article*> articles;
|
||||||
for (const auto article : articles_) {
|
for (const auto article : articles_) {
|
||||||
if (onlySold && article->isSold()) {
|
if (onlySold && article->isSold()) {
|
||||||
articles.push_back(article);
|
articles.push_back(article.get());
|
||||||
} else if (!onlySold) {
|
} else if (!onlySold) {
|
||||||
articles.push_back(article);
|
articles.push_back(article.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return articles;
|
return articles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t Seller::soldArticles() const { return getArticles(true).size(); }
|
|
@ -27,7 +27,8 @@ class Seller : public Entity
|
||||||
std::string getLastName() const;
|
std::string getLastName() const;
|
||||||
int getSellerNo() const;
|
int getSellerNo() const;
|
||||||
int getNumberOfOfferedArticles() const;
|
int getNumberOfOfferedArticles() const;
|
||||||
std::vector<std::shared_ptr<Article>> getArticles(bool onlySold = false);
|
size_t soldArticles() const;
|
||||||
|
std::vector<Article*> getArticles(bool onlySold = false) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int sellerNo_{-1};
|
int sellerNo_{-1};
|
||||||
|
|
Loading…
Reference in a new issue