| 32 | }; |
| 33 | |
| 34 | struct BankAccount |
| 35 | { |
| 36 | shared_ptr<OptionalLogger> log; |
| 37 | string name; |
| 38 | int balance = 0; |
| 39 | |
| 40 | static shared_ptr<Logger> no_logging; |
| 41 | |
| 42 | BankAccount(const string& name, int balance, const shared_ptr<Logger>& logger = no_logging) |
| 43 | : log{make_shared<OptionalLogger>(logger)}, |
| 44 | name{name}, |
| 45 | balance{balance} |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | void deposit(int amount) |
| 50 | { |
| 51 | balance += amount; |
| 52 | log->info("Deposited $" /*+ lexical_cast<string>(amount) |
| 53 | + " to " + name + ", balance is now $" + lexical_cast<string>(balance)*/); |
| 54 | } |
| 55 | |
| 56 | void withdraw(int amount) |
| 57 | { |
| 58 | /*if (balance >= amount) |
| 59 | { |
| 60 | balance -= amount; |
| 61 | log->info("Withdrew $" + lexical_cast<string>(amount) |
| 62 | + " from " + name + ", $" + lexical_cast<string>(balance) + " left"); |
| 63 | } |
| 64 | else |
| 65 | { |
| 66 | log->warn("Tried to withdraw $" + lexical_cast<string>(amount) + |
| 67 | " from " + name + " but couldn't due to low balance"); |
| 68 | }*/ |
| 69 | } |
| 70 | }; |
| 71 | |
| 72 | shared_ptr<Logger> BankAccount::no_logging{}; |
| 73 |
nothing calls this directly
no outgoing calls
no test coverage detected