account: implement deposit, withdraw, and getter
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
bfa3196b62
commit
c89b8f22da
2 changed files with 19 additions and 2 deletions
15
account.cpp
15
account.cpp
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Add table
Reference in a new issue