SHARE
TWEET

Account.cpp

a guest Apr 21st, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma once
  2. #ifndef ACCOUNT_H
  3. #define ACCOUNT_H
  4. #include "Date.h"
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. struct Transaction
  10. {
  11.     Date date;
  12.     int transactionType; // 0, 1, 2 for account creation, deposit and withdrawal respectively
  13.     double amount;
  14. };
  15.  
  16. class Account {
  17.  
  18. private:
  19.     int accountNumber;
  20.     string ownerName;
  21. protected:
  22.     double balance;
  23.     static int numberAccounts;
  24.     Transaction *transactionHistory;
  25.     int numberTransactions;
  26. public:
  27.     Account(string ownerName_, double balance);
  28.     virtual bool withdraw(double amount, Date date_);
  29.     bool deposit(double amount, Date date_);
  30.     int getAccountNumber() const;
  31.     double getBalance() const;
  32.     static int getNumberAccounts();
  33.     virtual void print() const;
  34.  
  35. };
  36.  
  37. int Account::numberAccounts = 0;
  38.  
  39. class RegularAccount : public Account {
  40.  
  41. public:
  42.     RegularAccount(string ownerName_, double balance_, Date &date_) : Account(ownerName_, balance_){};
  43.     void print() const;
  44. };
  45.  
  46.  
  47. class PremiumAccount : public Account {
  48.  
  49. private:
  50.     static double MIN_BALANCE;
  51. public:
  52.     PremiumAccount(string name, double amount):Account(name, amount) {};
  53.     bool withdraw(double amount, Date &date);
  54.     static double getMinBalance();
  55.     void print() const;
  56.  
  57. };
  58.  
  59. double PremiumAccount :: MIN_BALANCE = 1000;
  60.  
  61. #endif
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top