diff --git a/src/08_PTRN/Testat/BankAccount.cpp b/src/08_PTRN/Testat/BankAccount.cpp index 333c1c8..bb970d7 100644 --- a/src/08_PTRN/Testat/BankAccount.cpp +++ b/src/08_PTRN/Testat/BankAccount.cpp @@ -32,6 +32,3 @@ Money BankAccount::getMoney() { Person *BankAccount::getOwner() { return owner; } - - - diff --git a/src/10_PITF/Testat/Bank.cpp b/src/10_PITF/Testat/Bank.cpp index 9fbff68..4c7bc94 100644 --- a/src/10_PITF/Testat/Bank.cpp +++ b/src/10_PITF/Testat/Bank.cpp @@ -8,11 +8,11 @@ Bank::Bank(std::string name) : name(std::move(name)) { } void Bank::addAccount(std::unique_ptr account) { - accounts.insert(account); + accounts.insert(std::move(account)); } void Bank::addMoney(std::unique_ptr money) { - this->money.insert(money); + this->money.insert(std::move(money)); } std::set> Bank::getAccounts() { diff --git a/src/10_PITF/Testat/BankAccount.cpp b/src/10_PITF/Testat/BankAccount.cpp index ed0f045..48e067d 100644 --- a/src/10_PITF/Testat/BankAccount.cpp +++ b/src/10_PITF/Testat/BankAccount.cpp @@ -9,6 +9,18 @@ BankAccount::BankAccount(std::shared_ptr owner, std::string name) : name } +BankAccount::BankAccount(BankAccount *bankAccount) { + this->name = bankAccount->name; + money.swap(bankAccount->money); + owner.swap(bankAccount->owner); +} + +BankAccount::BankAccount(BankAccount &bankAccount) { + this->name = bankAccount.name; + money.swap(bankAccount.money); + owner.swap(bankAccount.owner); +} + std::unique_ptr BankAccount::operator+(Money* money) { std::unique_ptr ptr = std::make_unique(Money(money->getValue() + getMoney()->getValue(), money->getCurrency())); diff --git a/src/10_PITF/Testat/BankAccount.h b/src/10_PITF/Testat/BankAccount.h index d942d7c..a786f0d 100644 --- a/src/10_PITF/Testat/BankAccount.h +++ b/src/10_PITF/Testat/BankAccount.h @@ -1,7 +1,6 @@ #ifndef C_C_BANKACCOUNTS_H #define C_C_BANKACCOUNTS_H -#include #include #include "Money.h" @@ -15,6 +14,8 @@ private: std::unique_ptr money; public: explicit BankAccount(std::shared_ptr owner, std::string name); + explicit BankAccount(BankAccount *bankAccount); + BankAccount(BankAccount& bankAccount); std::unique_ptr operator+(Money* money); std::unique_ptr operator-(int value); bool operator<(std::unique_ptr bankAccount); diff --git a/src/10_PITF/Testat/Bill.cpp b/src/10_PITF/Testat/Bill.cpp index de9d70b..10fca77 100644 --- a/src/10_PITF/Testat/Bill.cpp +++ b/src/10_PITF/Testat/Bill.cpp @@ -6,6 +6,10 @@ Bill::Bill(int value, Currency currency, std::string serial) : Cash(value, curre } +Bill::Bill(Bill *bill) : Cash(bill->getValue(), bill->getCurrency()), serial(bill->getSerial()){ + +} + int Bill::getValue() { return Money::getValue() * 10; } diff --git a/src/10_PITF/Testat/Bill.h b/src/10_PITF/Testat/Bill.h index a747b00..542888c 100644 --- a/src/10_PITF/Testat/Bill.h +++ b/src/10_PITF/Testat/Bill.h @@ -9,6 +9,7 @@ private: std::string serial; public: Bill(int value, Currency currency, std::string serial); + explicit Bill(Bill *bill); std::string getSerial(); int getValue() override; }; diff --git a/src/10_PITF/Testat/Coin.cpp b/src/10_PITF/Testat/Coin.cpp index f7d15cb..685fb87 100644 --- a/src/10_PITF/Testat/Coin.cpp +++ b/src/10_PITF/Testat/Coin.cpp @@ -4,6 +4,10 @@ Coin::Coin(int value, Currency currency) : Cash(value, currency) { } +Coin::Coin(Coin *coin) : Cash(coin->getValue(), coin->getCurrency()) { + +} + int Coin::getValue() { return Money::getValue(); -} \ No newline at end of file +} diff --git a/src/10_PITF/Testat/Coin.h b/src/10_PITF/Testat/Coin.h index 9195945..65f71d1 100644 --- a/src/10_PITF/Testat/Coin.h +++ b/src/10_PITF/Testat/Coin.h @@ -8,6 +8,7 @@ class Coin : public Cash{ private: public: Coin(int value, Currency currency); + explicit Coin(Coin *coin); int getValue() override; }; diff --git a/src/10_PITF/Testat/main.cpp b/src/10_PITF/Testat/main.cpp index bfc020b..bed1c58 100644 --- a/src/10_PITF/Testat/main.cpp +++ b/src/10_PITF/Testat/main.cpp @@ -68,15 +68,15 @@ void setup() { owners.insert(alex); - bank1->addAccount(std::make_unique(BankAccount(max, "Konto 1"))); - bank2->addAccount(std::make_unique(BankAccount(max, "Konto 2"))); - bank3->addAccount(std::make_unique(BankAccount(alex, "privat"))); - bank1->addAccount(std::make_unique(BankAccount(alex, "geschäftlich 1"))); - bank2->addAccount(std::make_unique(BankAccount(alex, "geschäftlich 2"))); - bank3->addAccount(std::make_unique(BankAccount(alex, "geschäftlich 3"))); - bank1->addAccount(std::make_unique(BankAccount(marius, "Konto 1"))); - bank2->addAccount(std::make_unique(BankAccount(marius, "Konto 2"))); - bank3->addAccount(std::make_unique(BankAccount(marius, "Konto 3"))); + bank1->addAccount(std::make_unique(new BankAccount(max, "Konto 1"))); + bank2->addAccount(std::make_unique(new BankAccount(max, "Konto 2"))); + bank3->addAccount(std::make_unique(new BankAccount(alex, "privat"))); + bank1->addAccount(std::make_unique(new BankAccount(alex, "geschäftlich 1"))); + bank2->addAccount(std::make_unique(new BankAccount(alex, "geschäftlich 2"))); + bank3->addAccount(std::make_unique(new BankAccount(alex, "geschäftlich 3"))); + bank1->addAccount(std::make_unique(new BankAccount(marius, "Konto 1"))); + bank2->addAccount(std::make_unique(new BankAccount(marius, "Konto 2"))); + bank3->addAccount(std::make_unique(new BankAccount(marius, "Konto 3"))); banks.insert(std::move(bank1)); banks.insert(std::move(bank2));