@@ -8,34 +8,43 @@ class BankAccount {
88 double balance;
99
1010public:
11- // Constructor
12- BankAccount (){
13- // TODO: Implement the constructor
11+ // Default constructor
12+ BankAccount () {
13+ accountNumber = " " ;
14+ accountHolderName = " " ;
15+ balance = 0 ;
1416 }
1517
16- BankAccount (const std::string& accNumber, const std::string& accHolder, double initialBalance){
17- // TODO: Implement the constructor
18+ // Custom constructor
19+ BankAccount (const std::string& accNumber, const std::string& accHolder, double initialBalance) {
20+ accountNumber = accNumber;
21+ accountHolderName = accHolder;
22+ balance = initialBalance;
1823 }
1924
2025 // Deposit method
2126 void Deposit (double amount) {
22- // TODO: Implement the Deposit method
27+ if (amount > 0 ) {
28+ balance += amount;
29+ }
2330 }
2431
2532 // Withdraw method
2633 void Withdraw (double amount) {
27- // TODO: Implement the Deposit method
34+ if (amount > 0 && amount <= balance) {
35+ balance -= amount;
36+ }
2837 }
2938
30- // Display account information
39+ // Display account info
3140 void DisplayAccountInfo () {
32- // TODO: Implement the DisplayAccountInfo method
41+ std::cout << " Account Holder: " << accountHolderName << " \n " ;
42+ std::cout << " Account Number: " << accountNumber << " \n " ;
43+ std::cout << " Balance: $" << balance << " \n " ;
3344 }
3445
46+ // Get balance
3547 double GetBalance () const {
36- std::cout << " Test" << std::endl;
3748 return balance;
3849 }
3950};
40-
41-
0 commit comments