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() : 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; }
|
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::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; }
|
bool Article::isSold() { return salePtr_ ? true : false; }
|
||||||
|
|
||||||
std::string Article::getDescription() { return description_; }
|
std::string Article::getDescription() { return description_; }
|
||||||
|
|
||||||
Seller* Article::getSeller() { return sellerPtr_.get(); }
|
Seller* Article::getSeller() { return sellerPtr_; }
|
||||||
|
|
||||||
int Article::getPrice() { return price_; }
|
int Article::getPrice() { return price_; }
|
|
@ -15,21 +15,22 @@ class Article : public Entity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Article();
|
Article();
|
||||||
Article(std::shared_ptr<Seller> sellerPtr);
|
//Article(std::shared_ptr<Seller> sellerPtr);
|
||||||
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);
|
||||||
bool isSold();
|
bool isSold();
|
||||||
void setSale(std::shared_ptr<Sale> salePtr);
|
void setSale(Sale* salePtr);
|
||||||
void setSeller(std::shared_ptr<Seller> sellerPtr);
|
//void setSeller(std::shared_ptr<Seller> sellerPtr);
|
||||||
|
void setSeller(Seller* sellerPtr);
|
||||||
|
|
||||||
std::string getDescription();
|
std::string getDescription();
|
||||||
Seller* getSeller();
|
Seller* getSeller();
|
||||||
int getPrice();
|
int getPrice();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Seller> sellerPtr_{};
|
Seller* sellerPtr_{};
|
||||||
std::shared_ptr<Sale> salePtr_{};
|
Sale* salePtr_{};
|
||||||
int articleNo_{};
|
int articleNo_{};
|
||||||
int price_{};
|
int price_{};
|
||||||
std::string description_{};
|
std::string description_{};
|
||||||
|
|
|
@ -16,6 +16,6 @@ BOOST_AUTO_TEST_CASE(check_is_sold)
|
||||||
BOOST_TEST(article.isSold() == false);
|
BOOST_TEST(article.isSold() == false);
|
||||||
|
|
||||||
auto salePtr = std::make_shared<Sale>();
|
auto salePtr = std::make_shared<Sale>();
|
||||||
article.setSale(salePtr);
|
article.setSale(salePtr.get());
|
||||||
BOOST_TEST(article.isSold() == true);
|
BOOST_TEST(article.isSold() == true);
|
||||||
}
|
}
|
Loading…
Reference in a new issue