08_PTRN & 10_PITF: Testate bestanden

This commit is contained in:
Johannes Theiner 2019-01-08 11:09:46 +01:00
parent 808bb073bb
commit b1f037826c
6 changed files with 8 additions and 8 deletions

View File

@ -8,6 +8,7 @@ this->owner = owner;
BankAccount * BankAccount::operator+(Money * money) {
BankAccount::money = new Money(money->getValue() + getMoney().getValue());
return this;
}

View File

@ -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;
}

View File

@ -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)){
}

View File

@ -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;

View File

@ -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;
}

View File

@ -35,17 +35,17 @@ std::ostream &operator<<(std::ostream &os, Cash cash) {
return os;
}
std::ostream &operator<<(std::ostream &os, std::shared_ptr<Money> money) {
std::ostream &operator<<(std::ostream &os, const std::shared_ptr<Money> &money) {
os << money->getValue() << " " << money->getCurrency();
return os;
}
std::ostream &operator<<(std::ostream &os, std::shared_ptr<Person> person) {
std::ostream &operator<<(std::ostream &os, const std::shared_ptr<Person> &person) {
os << person->getName();
return os;
}
std::ostream &operator<<(std::ostream &os, std::shared_ptr<BankAccount> bankAccount) {
std::ostream &operator<<(std::ostream &os, const std::shared_ptr<BankAccount> &bankAccount) {
os << bankAccount->getOwner() << " " << bankAccount->getName() << ": " << bankAccount->getMoney();
return os;
}