08_PTRN & 10_PITF: Testate bestanden
This commit is contained in:
parent
808bb073bb
commit
b1f037826c
@ -8,6 +8,7 @@ this->owner = owner;
|
||||
BankAccount * BankAccount::operator+(Money * money) {
|
||||
|
||||
BankAccount::money = new Money(money->getValue() + getMoney().getValue());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)){
|
||||
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user