Compare commits

..

No commits in common. "7c40ea6f9795486b08dadcebfbe437fbd118015e" and "2131f122375cbeb10a1a5370de0d2a043d03b4a3" have entirely different histories.

4 changed files with 10 additions and 17 deletions

View file

@ -10,10 +10,8 @@ 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(); }

View file

@ -18,13 +18,11 @@ 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_{};

View file

@ -30,17 +30,15 @@ std::string Seller::getLastName() const { return lastName_; }
int Seller::getSellerNo() const { return sellerNo_; } 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_) { for (const auto article : articles_) {
if (onlySold && article->isSold()) { if (onlySold && article->isSold()) {
articles.push_back(article.get()); articles.push_back(article);
} else if (!onlySold) { } else if (!onlySold) {
articles.push_back(article.get()); articles.push_back(article);
} }
} }
return articles; return articles;
} }
size_t Seller::soldArticles() const { return getArticles(true).size(); }

View file

@ -27,8 +27,7 @@ class Seller : public Entity
std::string getLastName() const; std::string getLastName() const;
int getSellerNo() const; int getSellerNo() const;
int getNumberOfOfferedArticles() const; int getNumberOfOfferedArticles() const;
size_t soldArticles() const; std::vector<std::shared_ptr<Article>> getArticles(bool onlySold = false);
std::vector<Article*> getArticles(bool onlySold = false) const;
private: private:
int sellerNo_{-1}; int sellerNo_{-1};