From b1f037826ccbe6141b33c85105d1b98437db911a Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Tue, 8 Jan 2019 11:09:46 +0100 Subject: [PATCH] 08_PTRN & 10_PITF: Testate bestanden --- src/08_PTRN/Testat/BankAccount.cpp | 1 + src/08_PTRN/Testat/main.cpp | 3 ++- src/10_PITF/Testat/Bill.cpp | 2 +- src/10_PITF/Testat/Bill.h | 2 +- src/10_PITF/Testat/HeapObject.cpp | 2 -- src/10_PITF/Testat/main.cpp | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/08_PTRN/Testat/BankAccount.cpp b/src/08_PTRN/Testat/BankAccount.cpp index bb970d7..d37fd23 100644 --- a/src/08_PTRN/Testat/BankAccount.cpp +++ b/src/08_PTRN/Testat/BankAccount.cpp @@ -8,6 +8,7 @@ this->owner = owner; BankAccount * BankAccount::operator+(Money * money) { BankAccount::money = new Money(money->getValue() + getMoney().getValue()); + return this; } diff --git a/src/08_PTRN/Testat/main.cpp b/src/08_PTRN/Testat/main.cpp index 6438d40..d00905a 100644 --- a/src/08_PTRN/Testat/main.cpp +++ b/src/08_PTRN/Testat/main.cpp @@ -94,7 +94,8 @@ int main(int argc, char **argv) { *bankAccount + coin; } - Money * fee = * bankAccount - 10; + Money * fee = *bankAccount - 10; + delete fee; } std::cout << *bankAccount << std::endl; } diff --git a/src/10_PITF/Testat/Bill.cpp b/src/10_PITF/Testat/Bill.cpp index 5bf83a9..49a5d3e 100644 --- a/src/10_PITF/Testat/Bill.cpp +++ b/src/10_PITF/Testat/Bill.cpp @@ -4,7 +4,7 @@ using namespace banking; -Bill::Bill(int value, Currency currency, std::string serial) : Cash(value, currency), serial(std::move(serial)){ +Bill::Bill(int value, Currency currency, std::string &serial) : Cash(value, currency), serial(std::move(serial)){ } diff --git a/src/10_PITF/Testat/Bill.h b/src/10_PITF/Testat/Bill.h index f3e82c5..35be3d5 100644 --- a/src/10_PITF/Testat/Bill.h +++ b/src/10_PITF/Testat/Bill.h @@ -18,7 +18,7 @@ namespace banking { private: std::string serial; public: - explicit Bill(int value, Currency currency, std::string serial); + explicit 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/HeapObject.cpp b/src/10_PITF/Testat/HeapObject.cpp index 625b16f..07d8fd5 100644 --- a/src/10_PITF/Testat/HeapObject.cpp +++ b/src/10_PITF/Testat/HeapObject.cpp @@ -22,8 +22,6 @@ HeapObject::~HeapObject(){ bool HeapObject::assertionsHold() { //assert(ctorCount == newCount); // all objects have been allocated on heap - std::cout << std::endl; - std::cout << ctorCount << " " << dtorCount << std::endl; assert(ctorCount == dtorCount); // all objects have been deleted return true; } \ No newline at end of file diff --git a/src/10_PITF/Testat/main.cpp b/src/10_PITF/Testat/main.cpp index 4935978..fb71e3c 100644 --- a/src/10_PITF/Testat/main.cpp +++ b/src/10_PITF/Testat/main.cpp @@ -35,17 +35,17 @@ std::ostream &operator<<(std::ostream &os, Cash cash) { return os; } -std::ostream &operator<<(std::ostream &os, std::shared_ptr money) { +std::ostream &operator<<(std::ostream &os, const std::shared_ptr &money) { os << money->getValue() << " " << money->getCurrency(); return os; } -std::ostream &operator<<(std::ostream &os, std::shared_ptr person) { +std::ostream &operator<<(std::ostream &os, const std::shared_ptr &person) { os << person->getName(); return os; } -std::ostream &operator<<(std::ostream &os, std::shared_ptr bankAccount) { +std::ostream &operator<<(std::ostream &os, const std::shared_ptr &bankAccount) { os << bankAccount->getOwner() << " " << bankAccount->getName() << ": " << bankAccount->getMoney(); return os; }