kima2/src/core/article.cpp

38 lines
1.1 KiB
C++
Raw Normal View History

2018-07-09 16:06:27 +02:00
#include "article.h"
2018-07-23 14:25:18 +02:00
#include <iomanip>
#include <sstream>
2018-07-21 19:24:56 +02:00
// Article::Article() : Entity() {}
Article::Article(int price) : price_(price) {}
2018-07-09 16:06:27 +02:00
2018-07-12 14:37:56 +02:00
// Article::Article(std::shared_ptr<Seller> sellerPtr) : Entity() { sellerPtr_ = sellerPtr; }
2018-07-09 16:06:27 +02:00
2018-07-11 12:52:57 +02:00
void Article::setArticleNo(int articleNo) { articleNo_ = articleNo; }
2018-07-09 16:06:27 +02:00
2018-07-11 12:52:57 +02:00
void Article::setPrice(int price) { price_ = price; }
2018-07-09 16:06:27 +02:00
2018-07-11 12:52:57 +02:00
void Article::setDescription(const std::string& description) { description_ = description; }
2018-07-12 14:37:56 +02:00
void Article::setSale(Sale* salePtr) { salePtr_ = salePtr; }
void Article::setSeller(Seller* sellerPtr) { sellerPtr_ = sellerPtr; }
2018-07-11 12:52:57 +02:00
2018-07-12 12:06:55 +02:00
bool Article::isSold() { return salePtr_ ? true : false; }
std::string Article::getDescription() { return description_; }
2018-07-12 14:37:56 +02:00
Seller* Article::getSeller() { return sellerPtr_; }
2018-07-12 13:36:13 +02:00
2018-07-20 11:52:26 +02:00
int Article::getPrice() const { return price_; }
2018-07-13 13:04:30 +02:00
2018-07-23 14:25:18 +02:00
std::string Article::getPriceAsString() const
{
std::stringstream sumStream;
2018-07-24 15:37:19 +02:00
//sumStream.imbue(std::locale("de_DE.utf8"));
2018-07-23 21:21:05 +02:00
sumStream << std::right << std::setw(12) << std::showbase << std::put_money(price_, false);
2018-07-23 14:25:18 +02:00
return sumStream.str();
}
2018-07-20 11:52:26 +02:00
int Article::getArticleNo() { return articleNo_; }