Guest User

Untitled

a guest
Dec 8th, 2012
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.44 KB | None | 0 0
  1. // BankAccount.h
  2. // BankAccount class definition
  3. #include <string>
  4.  
  5. class BankAccount
  6. {
  7. protected:
  8. float balance;
  9. int account_number;
  10.  std::string account_name;
  11.  
  12. public:
  13. // BankAccount();
  14. void set_balance(float opening_balance);
  15. float get_balance();
  16. std::string get_name();
  17. void set_name(std::string name);
  18. void deposit(float deposit_amount);
  19.  void withdraw(float withdraw_amount);
  20. void set_account_number(int accountnum);
  21.     int get_account_number();
  22.  
  23. };
  24.  
  25. class CurrentAccount : public BankAccount
  26. {
  27. private:
  28.     bool balance_OK;
  29.     float minimum_balance;
  30. public:
  31.     void set_interest_rate(float interest);
  32.     float get_interest_rate();
  33.     float interest_rate;
  34.     CurrentAccount();
  35.     bool checkBalance();
  36. };
  37.  
  38. CurrentAccount::CurrentAccount()
  39. {
  40.     interest_rate = 0.5;
  41.     minimum_balance = 50.0;
  42. }
  43. bool CurrentAccount::checkBalance()
  44. {
  45.     balance_OK = true;
  46.     if (balance <=minimum_balance)
  47.         balance_OK = false;
  48.     return balance_OK;
  49. }
  50. void CurrentAccount::set_interest_rate (float interest)
  51. {
  52.     interest_rate = interest;
  53. }
  54.  
  55. float CurrentAccount::get_interest_rate()
  56. {
  57.     return interest_rate;
  58. }
  59.  
  60.  
  61. class DepositAccount : public BankAccount
  62. {
  63. private:
  64.     bool balance_OK;
  65.     float minimum_balance;
  66. public:
  67.     void set_interest_rate(float interest);
  68.     float get_interest_rate();
  69.     float interest_rate;
  70.     DepositAccount();
  71.     bool checkBalance();
  72. };
  73.  
  74. DepositAccount::DepositAccount()
  75. {
  76.     interest_rate = 2.5;
  77.     minimum_balance = 1000.00;
  78. }
  79. bool DepositAccount::checkBalance()
  80. {
  81.     balance_OK = true;
  82.     if (balance <=minimum_balance)
  83.     {
  84.         balance_OK = false;
  85.     (balance -= 25 );
  86. }
  87.     return balance_OK;
  88. }
  89.  
  90.  
  91. void DepositAccount::set_interest_rate (float interest)
  92. {
  93.     interest_rate = interest;
  94. }
  95.  
  96. float DepositAccount::get_interest_rate()
  97. {
  98.     return interest_rate;
  99. }
  100.  
  101.  
  102.  
  103.  
  104. void BankAccount::set_balance (float opening_balance)
  105. {
  106. balance = opening_balance;
  107. }
  108. float BankAccount::get_balance()
  109.  
  110. {
  111. return balance;
  112. }
  113.  
  114. void BankAccount::deposit (float deposit_amount)
  115. {
  116.  balance += deposit_amount;
  117. }
  118.  
  119. void BankAccount::withdraw(float withdraw_amount)
  120. {    
  121.  balance -= withdraw_amount;
  122. }
  123. void BankAccount::set_name (std::string name)
  124. {
  125. account_name = name;
  126. }
  127.  
  128. std::string BankAccount::get_name()
  129. {
  130. return account_name;
  131. }
  132.  
  133. void BankAccount::set_account_number (int accountnum)
  134. {
  135.     account_number = accountnum;
  136. }
  137. int BankAccount::get_account_number()
  138. {
  139.     return account_number;
  140. }
Advertisement
Add Comment
Please, Sign In to add comment