10_PITF: weitere Änderungen, immernoch die selbe Fehlermeldung
This commit is contained in:
parent
65d5e297e7
commit
568a5bc98e
|
@ -3,12 +3,17 @@
|
|||
|
||||
#include "Bank.h"
|
||||
|
||||
Bank::Bank(std::string name) : name(std::move(name)) {
|
||||
Bank::Bank(std::string const& name) : name(name) {
|
||||
|
||||
}
|
||||
|
||||
Bank::Bank(Bank* bank) : name(bank->name) {
|
||||
money.swap(bank->money);
|
||||
accounts.swap(bank->accounts);
|
||||
}
|
||||
|
||||
void Bank::addAccount(std::unique_ptr<BankAccount> account) {
|
||||
accounts.insert(std::move(account));
|
||||
this->accounts.insert(std::move(account));
|
||||
}
|
||||
|
||||
void Bank::addMoney(std::unique_ptr<Money> money) {
|
||||
|
|
|
@ -10,7 +10,8 @@ private:
|
|||
std::set<std::unique_ptr<BankAccount>> accounts;
|
||||
std::set<std::unique_ptr<Money>> money;
|
||||
public:
|
||||
explicit Bank(std::string name);
|
||||
explicit Bank(std::string const& name);
|
||||
explicit Bank(Bank* bank);
|
||||
void addAccount(std::unique_ptr<BankAccount> account);
|
||||
void addMoney(std::unique_ptr<Money> money);
|
||||
std::set<std::unique_ptr<BankAccount>> getAccounts();
|
||||
|
|
|
@ -5,18 +5,16 @@
|
|||
#include "BankAccount.h"
|
||||
#include "CashFactory.h"
|
||||
|
||||
BankAccount::BankAccount(std::shared_ptr<Person> owner, std::string name) : name(std::move(name)), owner(std::move(owner)) {
|
||||
BankAccount::BankAccount(std::shared_ptr<Person> const& owner, std::string const& name) : name(name), owner(std::move(owner)) {
|
||||
|
||||
}
|
||||
|
||||
BankAccount::BankAccount(BankAccount *bankAccount) {
|
||||
this->name = bankAccount->name;
|
||||
BankAccount::BankAccount(BankAccount *bankAccount) : name(bankAccount->name) {
|
||||
money.swap(bankAccount->money);
|
||||
owner.swap(bankAccount->owner);
|
||||
}
|
||||
|
||||
BankAccount::BankAccount(BankAccount &bankAccount) {
|
||||
this->name = bankAccount.name;
|
||||
BankAccount::BankAccount(BankAccount &bankAccount) : name(bankAccount.name) {
|
||||
money.swap(bankAccount.money);
|
||||
owner.swap(bankAccount.owner);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ private:
|
|||
std::shared_ptr<Person> owner;
|
||||
std::unique_ptr<Money> money;
|
||||
public:
|
||||
explicit BankAccount(std::shared_ptr<Person> owner, std::string name);
|
||||
explicit BankAccount(std::shared_ptr<Person> const& owner, std::string const& name);
|
||||
explicit BankAccount(BankAccount *bankAccount);
|
||||
BankAccount(BankAccount& bankAccount);
|
||||
std::unique_ptr<BankAccount> operator+(Money* money);
|
||||
|
|
|
@ -2,10 +2,14 @@
|
|||
|
||||
#include "Person.h"
|
||||
|
||||
Person::Person(std::string name) : name(std::move(name)){
|
||||
Person::Person(std::string const& name) : name(name) {
|
||||
|
||||
}
|
||||
|
||||
Person::Person(Person *person) : name(person->name) {
|
||||
money.swap(person->money);
|
||||
}
|
||||
|
||||
std::string Person::getName() {
|
||||
return name;
|
||||
}
|
|
@ -12,7 +12,8 @@ private:
|
|||
std::string name;
|
||||
std::vector<std::unique_ptr<Money>> money;
|
||||
public:
|
||||
explicit Person(std::string name);
|
||||
explicit Person(std::string const& name);
|
||||
explicit Person(Person* person);
|
||||
std::string getName();
|
||||
};
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ std::ostream &operator<<(std::ostream &os, std::unique_ptr<Money> money) {
|
|||
return os;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, std::shared_ptr<Person> person) {
|
||||
std::ostream &operator<<(std::ostream &os, std::shared_ptr<Person> const& person) {
|
||||
os << person->getName();
|
||||
return os;
|
||||
}
|
||||
|
@ -55,13 +55,13 @@ CashFactory *cashFactory;
|
|||
|
||||
void setup() {
|
||||
|
||||
std::unique_ptr<Bank> bank1 = std::make_unique<Bank>(Bank("Bank 1"));
|
||||
std::unique_ptr<Bank> bank2 = std::make_unique<Bank>(Bank("Bank 2"));
|
||||
std::unique_ptr<Bank> bank3 = std::make_unique<Bank>(Bank("Bank 3"));
|
||||
std::unique_ptr<Bank> bank1 = std::make_unique<Bank>(new Bank("Bank 1"));
|
||||
std::unique_ptr<Bank> bank2 = std::make_unique<Bank>(new Bank("Bank 2"));
|
||||
std::unique_ptr<Bank> bank3 = std::make_unique<Bank>(new Bank("Bank 3"));
|
||||
|
||||
std::shared_ptr<Person> max = std::make_shared<Person>(Person("Max Müller"));
|
||||
std::shared_ptr<Person> marius = std::make_shared<Person>(Person("Marius Müller"));
|
||||
std::shared_ptr<Person> alex = std::make_shared<Person>(Person("Alex Maier"));
|
||||
std::shared_ptr<Person> max = std::make_shared<Person>(new Person("Max Müller"));
|
||||
std::shared_ptr<Person> marius = std::make_shared<Person>(new Person("Marius Müller"));
|
||||
std::shared_ptr<Person> alex = std::make_shared<Person>(new Person("Alex Maier"));
|
||||
|
||||
owners.insert(max);
|
||||
owners.insert(marius);
|
||||
|
|
Loading…
Reference in New Issue