-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccounts.cpp
More file actions
79 lines (69 loc) · 2.22 KB
/
Accounts.cpp
File metadata and controls
79 lines (69 loc) · 2.22 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
72
73
74
75
76
77
78
79
#include "Accounts.h"
#include <iostream>
#include <vector>
#include <string>
using namespace std;
Accounts::Accounts() { //Constructor
}
Accounts::~Accounts() { //Destructor
}
bool Accounts::add_account(vector<Account>& accounts, string name){
for (auto& a : accounts) {
if (a.get_name() == name)
return false;
}
Account addAccount(name);
accounts.push_back(addAccount);
return true;
}
void Accounts::set_account_balance(vector<Account>& accounts,int i,long double bal) {
accounts[i].set_balance(bal);
}
void Accounts::account_deposit(vector <Account>& accounts, int i, long double dep) {
accounts[i].set_deposit(dep);
}
void Accounts::account_withdraw(vector<Account>& accounts, int i, long double wthdrl) {
if (accounts[i].set_withdrawl(wthdrl))
cout << "\n$" << wthdrl << " has been successfully withdrawn from your account." << endl;
else
cout << "\nInsufficient Funds." << endl;
}
void Accounts::view_balance(std::vector<Account>& accounts, int i) {
cout << "\nBalance: $" << accounts[i].view_balance() << endl;
}
void Accounts::transfer(vector <Account>& accounts, int i) { //make sure to subtract funds that have been transfered and check to see if available
int j;
long double tran;
display_accounts(accounts);
cout << "Choose an Account to transfer to: ";
cin >> j;
cout << "\nHow much would you like to transfer to " << accounts[j - 1].get_name() << "'s account?: $";
cin >> tran;
if (accounts[i].set_tranfer(tran))
{
accounts[j - 1].set_deposit(tran);
cout << "\n$" << tran << " has been successfully tranfered to " << accounts[j - 1].get_name() << "'s account." << endl;
}
else
{
cout << "Insufficent funds!" << endl;
}
}
bool Accounts::display_accounts(vector<Account>& accounts) const {
int i = 1;
if (accounts.size() == 0) {
return false;
}
cout << "----- ACCOUNTS -----" << endl;
for (auto& x : accounts) {
cout << i++ <<".) "<< x.get_name() << endl;
}
}
void Accounts::name(vector<Account>& accounts, int i) {
cout << accounts[i].get_name() << endl;
}
void Accounts::delete_account(std::vector<Account>& accounts, int i)
{
accounts.erase(accounts.begin() + i);
std::cout << "Successfully Deleted." << std::endl;
}