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