diff --git a/src/core/article.cpp b/src/core/article.cpp index 3270da7..b56c413 100644 --- a/src/core/article.cpp +++ b/src/core/article.cpp @@ -10,8 +10,10 @@ void Article::setPrice(int price) { price_ = price; } void Article::setDescription(const std::string& description) { description_ = description; } -std::string Article::getDescription() { return description_; } - void Article::setSale(std::shared_ptr salePtr) { salePtr_ = salePtr; } -bool Article::isSold() { return salePtr_ ? true : false; } \ No newline at end of file +bool Article::isSold() { return salePtr_ ? true : false; } + +std::string Article::getDescription() { return description_; } + +Seller* Article::getSeller() { return sellerPtr_.get(); } \ No newline at end of file diff --git a/src/core/article.h b/src/core/article.h index 1d0487b..4042924 100644 --- a/src/core/article.h +++ b/src/core/article.h @@ -18,11 +18,13 @@ 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 salePtr); void setSeller(std::shared_ptr sellerPtr); + std::string getDescription(); + Seller* getSeller(); + private: std::shared_ptr sellerPtr_{}; std::shared_ptr salePtr_{}; diff --git a/src/core/seller.cpp b/src/core/seller.cpp index 5e7edae..94d3a0d 100644 --- a/src/core/seller.cpp +++ b/src/core/seller.cpp @@ -30,15 +30,17 @@ std::string Seller::getLastName() const { return lastName_; } int Seller::getSellerNo() const { return sellerNo_; } -std::vector> Seller::getArticles(bool onlySold) +std::vector Seller::getArticles(bool onlySold) const { - std::vector> articles; + std::vector articles; for (const auto article : articles_) { if (onlySold && article->isSold()) { - articles.push_back(article); + articles.push_back(article.get()); } else if (!onlySold) { - articles.push_back(article); + articles.push_back(article.get()); } } return articles; -} \ No newline at end of file +} + +size_t Seller::soldArticles() const { return getArticles(true).size(); } \ No newline at end of file diff --git a/src/core/seller.h b/src/core/seller.h index 63aebb2..a713292 100644 --- a/src/core/seller.h +++ b/src/core/seller.h @@ -27,7 +27,8 @@ class Seller : public Entity std::string getLastName() const; int getSellerNo() const; int getNumberOfOfferedArticles() const; - std::vector> getArticles(bool onlySold = false); + size_t soldArticles() const; + std::vector getArticles(bool onlySold = false) const; private: int sellerNo_{-1};