-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.cpp
More file actions
65 lines (56 loc) · 829 Bytes
/
Account.cpp
File metadata and controls
65 lines (56 loc) · 829 Bytes
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Account.cpp
*
* Created on: Dec 8, 2014
* Author: explicitness
*/
#include "Account.h"
using namespace std;
Account::Account(void):balance(0)
{
}
vector<string> Account::Report()
{
vector<string> report;
report.push_back("Balance is " + to_string(balance));
report.push_back("Transactions: ");
for (auto t:log)
{
report.push_back(t.Report());
}
report.push_back("------------------");
return report;
}
bool Account::Deposit(int amt)
{
if (amt >= 0)
{
balance += amt;
log.push_back(Transaction(amt,"Deposit"));
return true;
}
else
{
return false;
}
}
bool Account::Withdraw(int amt)
{
if (amt >= 0)
{
if (balance >= amt)
{
balance -= amt;
log.push_back(Transaction(amt, "Withdraw"));
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}