account: implement deposit, withdraw, and getter

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2025-02-08 11:18:25 -05:00
parent bfa3196b62
commit c89b8f22da
Signed by: vbatts
GPG key ID: E30EFAA812C6E5ED
2 changed files with 19 additions and 2 deletions

View file

@ -1,6 +1,4 @@
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
@ -10,4 +8,17 @@ Account::Account ( double initial_balance ) : balance(initial_balance) {
}
Account::~Account () {
cout << "account deleted" << endl;
}
double Account::getBalance() const {
return balance;
}
void Account::deposit(double amount) {
balance += amount;
}
void Account::withdraw(double amount) {
balance -= amount;
}

View file

@ -17,8 +17,14 @@ class Account
/* ==================== ACCESSORS ======================================= */
// current balance of the Account
double getBalance() const;
/* ==================== MUTATORS ======================================= */
void deposit(double amount);
void withdraw(double amount);
/* ==================== OPERATORS ======================================= */
Account& operator = ( const Account &other ); /* assignment operator */