I'd like for the code to have operator overloading and the ability to generate unique random account numbers but I do not know how to do that.
This is the original question:
Define the class bankAccount to store a bank customer’s account number and balance. Suppose that account number is of type int, and balance is of type double. Your class should, at least, provide the following operations: set the account number, retrieve the account number, retrieve the balance, deposit and withdraw money, and print account information. Add appropriate constructors.
Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount (designed in part a). This class inherits members to store the account number and the balance from the base class. A customer with a checking account typically receives interest, maintains a minimum balance, and pays service charges if the balance falls below the minimum balance. Add member variables to store this additional information. In addition to the operations inherited from the base class, this class should provide the following operations: set interest rate, retrieve interest rate, set minimum balance, retrieve minimum balance, set service charges, retrieve service charges, post interest, verify if the balance is less than the minimum balance, write a check, withdraw (override the method of the base class), and print account information. Add appropriate constructors.
Every bank offers a savings account. Derive the class savingsAccount from the class bankAccount (designed in part a). This class inherits members to store the account number and the balance from the base class. A customer with a savings account typically receives interest, makes deposits, and withdraws money. In addition to the operations inherited from the base class, this class should provide the following operations: set interest rate, retrieve interest rate, post interest, withdraw (override the method of the base class), and print account information. Add appropriate constructors.
Write a program to test your classes designed in parts b and c. Provide header and .cpp files.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
bankAccount.h
#ifndef BANKACCOUNT_H
#define BANKACCOUNT_H
#include <iostream>
using namespace std;
class bankAccount {
public:
bankAccount();
bankAccount(int, double);
void setAccountNumber(int);
int getAccountNum() const;
void setBalance(double);
double getBalance() const;
void deposit(double);
void withdraw(double);
void print() const;
private:
int accountNum;
double accountBalance;
};
#endif
|