forked from UoL-SoCS/uol-cmp9133-w2-cmp9133-w2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbank_account.hpp
More file actions
72 lines (61 loc) · 1.75 KB
/
Copy pathbank_account.hpp
File metadata and controls
72 lines (61 loc) · 1.75 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
#include <iostream>
#include <string>
using namespace std;
class BankAccount {
private:
std::string accountNumber;
std::string accountHolderName;
double balance;
public:
// Constructor
BankAccount(){
// TODO: Implement the constructor
cout << "Constructor" << endl;
accountNumber = "";
accountHolderName = "";
balance = 0.0;
}
BankAccount(const std::string& accNumber, const std::string& accHolder, double initialBalance){
// TODO: Implement the constructor
accountNumber = accNumber;
accountHolderName = accHolder;
if (initialBalance < 0) {
cout << "Initial Balance cannot be negative. Balance set to 0." << endl;
balance = 0.0;
}
else {
balance= initialBalance;
}
}
// Deposit method
void Deposit(double amount) {
if(amount<0){
cout <<"Negative amont is not premitted";
}
else{
balance += amount;
cout << "Current Balance: " << balance << endl;
}
}
// Withdraw method
void Withdraw(double amount) {
if (amount <= balance) {
balance -= amount;
cout << "Current Balance: " << balance << endl;
}
else {
cout << "Insufficnet Funds." << endl;
}
}
// Display account information
void DisplayAccountInfo() {
// TODO: Implement the DisplayAccountInfo method
cout << "Account Number: " << accountNumber << endl;
cout << "Account Holder Name: " << accountHolderName << endl;
cout << "Balance: £" << balance << endl;
}
double GetBalance() const {
std::cout << "Test" << std::endl;
return balance;
}
};