more on pointers
This commit is contained in:
parent
b69531ced4
commit
9c624065bb
3 changed files with 12 additions and 9 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
Article::Article() : Entity() {}
|
||||
|
||||
Article::Article(std::shared_ptr<Seller> sellerPtr) : Entity() { sellerPtr_ = sellerPtr; }
|
||||
// Article::Article(std::shared_ptr<Seller> sellerPtr) : Entity() { sellerPtr_ = sellerPtr; }
|
||||
|
||||
void Article::setArticleNo(int articleNo) { articleNo_ = articleNo; }
|
||||
|
||||
|
@ -10,12 +10,14 @@ 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; }
|
||||
void Article::setSale(Sale* salePtr) { salePtr_ = salePtr; }
|
||||
|
||||
void Article::setSeller(Seller* sellerPtr) { sellerPtr_ = sellerPtr; }
|
||||
|
||||
bool Article::isSold() { return salePtr_ ? true : false; }
|
||||
|
||||
std::string Article::getDescription() { return description_; }
|
||||
|
||||
Seller* Article::getSeller() { return sellerPtr_.get(); }
|
||||
Seller* Article::getSeller() { return sellerPtr_; }
|
||||
|
||||
int Article::getPrice() { return price_; }
|
|
@ -15,21 +15,22 @@ class Article : public Entity
|
|||
{
|
||||
public:
|
||||
Article();
|
||||
Article(std::shared_ptr<Seller> sellerPtr);
|
||||
//Article(std::shared_ptr<Seller> sellerPtr);
|
||||
void setArticleNo(int articleNo);
|
||||
void setPrice(int price);
|
||||
void setDescription(const std::string& description);
|
||||
bool isSold();
|
||||
void setSale(std::shared_ptr<Sale> salePtr);
|
||||
void setSeller(std::shared_ptr<Seller> sellerPtr);
|
||||
void setSale(Sale* salePtr);
|
||||
//void setSeller(std::shared_ptr<Seller> sellerPtr);
|
||||
void setSeller(Seller* sellerPtr);
|
||||
|
||||
std::string getDescription();
|
||||
Seller* getSeller();
|
||||
int getPrice();
|
||||
|
||||
private:
|
||||
std::shared_ptr<Seller> sellerPtr_{};
|
||||
std::shared_ptr<Sale> salePtr_{};
|
||||
Seller* sellerPtr_{};
|
||||
Sale* salePtr_{};
|
||||
int articleNo_{};
|
||||
int price_{};
|
||||
std::string description_{};
|
||||
|
|
|
@ -16,6 +16,6 @@ BOOST_AUTO_TEST_CASE(check_is_sold)
|
|||
BOOST_TEST(article.isSold() == false);
|
||||
|
||||
auto salePtr = std::make_shared<Sale>();
|
||||
article.setSale(salePtr);
|
||||
article.setSale(salePtr.get());
|
||||
BOOST_TEST(article.isSold() == true);
|
||||
}
|
Loading…
Reference in a new issue