Advertisement
uopspop

account.cpp

Apr 13th, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include "account.h"
  4. using namespace std;
  5.  
  6. Account::Account(int initial)
  7.     {
  8.         if (initial >= 0){
  9.             credit(initial);
  10.         }
  11.         else {
  12.             balance = 0;
  13.             cout << "invalid input for balance" << endl;
  14.         };
  15.     }
  16.  
  17.     void Account::credit(int amount)
  18.     {
  19.         balance += amount;
  20.     }
  21.  
  22.     void Account::debit(int amount)
  23.     {
  24.         if (amount > balance){
  25.             cout << "Debit amount exceeded account balance" << endl;
  26.         }else{
  27.             balance -= amount;
  28.         }
  29.  
  30.     }
  31.  
  32.     int Account::getBalance()
  33.     {
  34.         return balance;
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement