code cleanup
This commit is contained in:
parent
4f9151d85b
commit
f0ec980e8d
4 changed files with 17 additions and 13 deletions
|
@ -1,5 +1,9 @@
|
||||||
#include "entityint.h"
|
#include "entityint.h"
|
||||||
|
|
||||||
|
EntityInt::EntityInt(int id) {
|
||||||
|
id_ = id;
|
||||||
|
}
|
||||||
|
|
||||||
void EntityInt::setId(int id) {
|
void EntityInt::setId(int id) {
|
||||||
id_ = id;
|
id_ = id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,13 @@
|
||||||
|
|
||||||
class EntityInt : public Entity
|
class EntityInt : public Entity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
EntityInt() = default;
|
||||||
|
EntityInt(int id);
|
||||||
void setId(int id);
|
void setId(int id);
|
||||||
int getId() const {return id_;};
|
int getId() const { return id_; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int id_{};
|
int id_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,15 +7,14 @@
|
||||||
|
|
||||||
Seller::Seller(const std::string& firstName, const std::string& lastName, int sellerNo,
|
Seller::Seller(const std::string& firstName, const std::string& lastName, int sellerNo,
|
||||||
int numArticlesOffered)
|
int numArticlesOffered)
|
||||||
: EntityInt()
|
: EntityInt(sellerNo)
|
||||||
{
|
{
|
||||||
firstName_ = firstName;
|
firstName_ = firstName;
|
||||||
lastName_ = lastName;
|
lastName_ = lastName;
|
||||||
sellerNo_ = sellerNo;
|
|
||||||
numArticlesOffered_ = numArticlesOffered;
|
numArticlesOffered_ = numArticlesOffered;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Seller::setSellerNo(int seller_no) { sellerNo_ = seller_no; id_ = seller_no;}
|
void Seller::setSellerNo(int seller_no) { setId(seller_no); }
|
||||||
|
|
||||||
void Seller::setFirstName(const std::string& firstName) { firstName_ = firstName; }
|
void Seller::setFirstName(const std::string& firstName) { firstName_ = firstName; }
|
||||||
|
|
||||||
|
@ -33,13 +32,13 @@ std::string Seller::getFirstName() const { return firstName_; }
|
||||||
|
|
||||||
std::string Seller::getLastName() const { return lastName_; }
|
std::string Seller::getLastName() const { return lastName_; }
|
||||||
|
|
||||||
int Seller::getSellerNo() const { return sellerNo_; }
|
int Seller::getSellerNo() const { return getId(); }
|
||||||
|
|
||||||
std::string Seller::getSellerNoAsString() const
|
std::string Seller::getSellerNoAsString() const
|
||||||
{
|
{
|
||||||
std::stringstream selNoStr;
|
std::stringstream selNoStr;
|
||||||
|
|
||||||
selNoStr << std::setfill('0') << std::setw(3) << sellerNo_;
|
selNoStr << std::setfill('0') << std::setw(3) << id_;
|
||||||
|
|
||||||
return selNoStr.str();
|
return selNoStr.str();
|
||||||
;
|
;
|
||||||
|
@ -104,8 +103,8 @@ int Seller::sumInCents()
|
||||||
|
|
||||||
std::string Seller::sumAsString() { return formatCentAsEuroString(sumInCents()); }
|
std::string Seller::sumAsString() { return formatCentAsEuroString(sumInCents()); }
|
||||||
|
|
||||||
bool operator<(const Seller& li, const Seller& re) { return li.sellerNo_ < re.sellerNo_; }
|
bool operator<(const Seller& li, const Seller& re) { return li.id_ < re.id_; }
|
||||||
bool operator<(const std::unique_ptr<Seller>& li, const std::unique_ptr<Seller>& re)
|
bool operator<(const std::unique_ptr<Seller>& li, const std::unique_ptr<Seller>& re)
|
||||||
{
|
{
|
||||||
return li->sellerNo_ < re->sellerNo_;
|
return li->id_ < re->id_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Seller : public EntityInt
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Seller() = default;
|
Seller() = default;
|
||||||
// virtual ~Seller() = default;
|
~Seller() = default;
|
||||||
Seller(const std::string& firstName, const std::string& lastName, int sellerNo = 0,
|
Seller(const std::string& firstName, const std::string& lastName, int sellerNo = 0,
|
||||||
int numArticlesOffered = 0);
|
int numArticlesOffered = 0);
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@ class Seller : public EntityInt
|
||||||
friend bool operator<(const std::unique_ptr<Seller>& li, const std::unique_ptr<Seller>& re);
|
friend bool operator<(const std::unique_ptr<Seller>& li, const std::unique_ptr<Seller>& re);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int sellerNo_{-1};
|
|
||||||
int numArticlesOffered_{};
|
int numArticlesOffered_{};
|
||||||
std::string firstName_{};
|
std::string firstName_{};
|
||||||
std::string lastName_{};
|
std::string lastName_{};
|
||||||
|
|
Loading…
Reference in a new issue