Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // BankAccount.h
- // BankAccount class definition
- #include <string>
- class BankAccount
- {
- protected:
- float balance;
- int account_number;
- std::string account_name;
- public:
- // BankAccount();
- void set_balance(float opening_balance);
- float get_balance();
- std::string get_name();
- void set_name(std::string name);
- void deposit(float deposit_amount);
- void withdraw(float withdraw_amount);
- void set_account_number(int accountnum);
- int get_account_number();
- };
- class CurrentAccount : public BankAccount
- {
- private:
- bool balance_OK;
- float minimum_balance;
- public:
- void set_interest_rate(float interest);
- float get_interest_rate();
- float interest_rate;
- CurrentAccount();
- bool checkBalance();
- };
- CurrentAccount::CurrentAccount()
- {
- interest_rate = 0.5;
- minimum_balance = 50.0;
- }
- bool CurrentAccount::checkBalance()
- {
- balance_OK = true;
- if (balance <=minimum_balance)
- balance_OK = false;
- return balance_OK;
- }
- void CurrentAccount::set_interest_rate (float interest)
- {
- interest_rate = interest;
- }
- float CurrentAccount::get_interest_rate()
- {
- return interest_rate;
- }
- class DepositAccount : public BankAccount
- {
- private:
- bool balance_OK;
- float minimum_balance;
- public:
- void set_interest_rate(float interest);
- float get_interest_rate();
- float interest_rate;
- DepositAccount();
- bool checkBalance();
- };
- DepositAccount::DepositAccount()
- {
- interest_rate = 2.5;
- minimum_balance = 1000.00;
- }
- bool DepositAccount::checkBalance()
- {
- balance_OK = true;
- if (balance <=minimum_balance)
- {
- balance_OK = false;
- (balance -= 25 );
- }
- return balance_OK;
- }
- void DepositAccount::set_interest_rate (float interest)
- {
- interest_rate = interest;
- }
- float DepositAccount::get_interest_rate()
- {
- return interest_rate;
- }
- void BankAccount::set_balance (float opening_balance)
- {
- balance = opening_balance;
- }
- float BankAccount::get_balance()
- {
- return balance;
- }
- void BankAccount::deposit (float deposit_amount)
- {
- balance += deposit_amount;
- }
- void BankAccount::withdraw(float withdraw_amount)
- {
- balance -= withdraw_amount;
- }
- void BankAccount::set_name (std::string name)
- {
- account_name = name;
- }
- std::string BankAccount::get_name()
- {
- return account_name;
- }
- void BankAccount::set_account_number (int accountnum)
- {
- account_number = accountnum;
- }
- int BankAccount::get_account_number()
- {
- return account_number;
- }
Advertisement
Add Comment
Please, Sign In to add comment