-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbank.cpp
More file actions
51 lines (43 loc) · 1.03 KB
/
bank.cpp
File metadata and controls
51 lines (43 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "account.h"
Bank::Bank(Domain *domain) : Firm(domain) //Account(domain)
{
}
void Bank::lend(double amount, double rate, Account *recipient)
{
recipient->loan(amount, rate, this);
balance -= amount;
}
/*
size_t Bank::getNumEmployees()
{
return Firm::getNumEmployees();
}
*/
/*
* this overloads the base funxtion in Account. For the time being it just
* duplicates the code but it will have to be modified to include additional
* processing.
*/
bool Bank::transferSafely(Account *recipient, double amount, Account *creditor)
{
if (amount > balance || recipient == nullptr)
{
// TODO: This needs to go into a log somewhere
qDebug() << "Account::transferSafely(): done (insufficient funds or no recipient)";
Q_ASSERT(false);
return false;
}
else
{
qDebug() << "crediting" << amount;
recipient->credit(amount, creditor);
balance -= amount;
return true;
}
}
/*
* Periodically clear funds owing to other banks
*/
void Bank::trigger(int)
{
}