-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.cpp
More file actions
71 lines (69 loc) · 1.48 KB
/
Account.cpp
File metadata and controls
71 lines (69 loc) · 1.48 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include"Account.h"
#include <iostream>
#include <iomanip>
using namespace std;
int Account::AccNum = 0;
double Account::getBalance()
{
return balance;
}
void Account::DepositTra(double money)
{
balance += money;
cout << "Your Balance Now is " << balance << "\n";
transactionHistory.push_back("Deposited $" + to_string(money));
}
void Account::WithdrawTra(double money)
{
try {
if (money > balance)
throw exception();
balance -= money;
cout << "Your Balance Now is " << balance << "\n";
transactionHistory.push_back("Withdrew $" + to_string(money));
}
catch (exception&) {
cout << "Failed on withdraw tansaction\n";
}
}
string Account::getAccountType()
{
return this->AccountType;
}
void Account::setAccountType(string type)
{
this->AccountType = type;
}
void Account::setBalance(double balance)
{
try {
if (balance < 0)
throw exception();
this->balance = balance;
}
catch (exception&)
{
cout << "wrong balance";
}
}
Account::Account() {};
Account::Account(int num, string type, double balance)
{
this->AccNum = num;
this->AccountType = type;
this->balance = balance;
}
int Account::getAccountNum()
{
return this->AccNum;
}
void Account::setAccountNum(int AccNum)
{
this->AccNum = AccNum;
}
void Account::displayTransactionHistory()
{
for (auto& transaction : transactionHistory) {
cout << transaction << "\n" <<std::endl;
}
}