-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBankAccount.cpp
82 lines (77 loc) · 1.8 KB
/
BankAccount.cpp
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
80
81
82
#include "BankAccount.h"
#include<iostream>
using namespace std;
BankAccount::BankAccount()
{
account_number = account_balance = 0;
account_holder_name = "---";
}
BankAccount::BankAccount(int acc_no, char* holder_name, int acc_bal)
{
setAccBalance(acc_bal);
setAccHolderName(holder_name);
setAccountNumber(acc_no);
}
void BankAccount::setAccBalance(int acc_balance)
{
account_balance = acc_balance;
}
void BankAccount::setAccHolderName(char* acc_hol_name)
{
account_holder_name = acc_hol_name;
}
void BankAccount::setAccountNumber(int acc_num)
{
account_number = acc_num;
}
int BankAccount::getAccBalance()
{
return account_balance;
}
char* BankAccount::getAccHolderName()
{
return account_holder_name;
}
int BankAccount::getAccNumber()
{
return account_number;
}
void BankAccount::addNewAcc(BankAccount *&obj,int &size)
{
BankAccount *obj = new BankAccount[size + 1];
for (int i = 0; i < size; i++)
{
*obj[i].setAccBalance = obj[i].getAccBalance();
*obj[i].setAccHolderName = obj[i].getAccHolderName();
*obj[i].setAccountNumber = obj[i].getAccNumber();
}
char* n_name; int n_balance; int n_acc_number;
cout << "Enter new account holder name:";
cin >> n_name;
obj[size].setAccHolderName(n_name);
cout << "Enter new account balance:";
cin >> n_balance;
obj[size].setAccBalance(n_balance);
cout << "Enter new account number:";
cin >> n_acc_number;
obj[size].setAccountNumber(n_acc_number);
}
void BankAccount::displayDetails()
{
cout << "Account holder name: " << getAccHolderName() << endl;
cout << "Account Balance: " << getAccBalance() << endl << endl;
}
int BankAccount::HighestBalanceAcc(BankAccount arr[], int size)
{
int highest = 0;
int index;
for (int i = 0; i < size; i++)
{
if (arr[i].getAccBalance()>highest)
{
highest = arr[i].getAccBalance();
index = i;
}
}
return index;
}