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
57 lines (48 loc) · 1.66 KB
/
Copy pathbank_account.hpp
File metadata and controls
57 lines (48 loc) · 1.66 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
#include <iostream>
#include <string>
class BankAccount {
private:
std::string accountNumber;
std::string accountHolderName;
double balance;
public:
// Constructor
BankAccount() : accountNumber(""), accountHolderName(""), balance(0.0) {
// Default initialization for an empty account
}
BankAccount(const std::string& accNumber, const std::string& accHolder, double initialBalance)
: accountNumber(accNumber), accountHolderName(accHolder), balance(initialBalance) {
// Constructor initializes the account with the provided values
}
// Deposit method
void Deposit(double amount) {
// TODO: Implement the Deposit method
if(amount > 0){
balance += amount;
std::cout << "Deposited " << amount << " to the account.\n";
} else {
std::cout << "Deposit amount must be positive.\n";
}
}
// Withdraw method
void Withdraw(double amount) {
// TODO: Implement the Deposit method
if(amount <= balance){
balance -= amount;
std::cout << "Withdrew " << amount << " from the account.\n";
} else {
std::cout << "Insufficient balance for withdrawal.\n";
}
}
// Display account information
void DisplayAccountInfo() {
// TODO: Implement the DisplayAccountInfo method
std::cout << "Account Number: " << accountNumber << std::endl;
std::cout << "Account Holder: " << accountHolderName << std::endl;
std::cout << "Balance: " << balance << std::endl;
}
double GetBalance() const {
std::cout << "Test" << std::endl;
return balance;
}
};