Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

It is C++, Inherit the BankAccount class in two other classes, SavingsAccount, WalletAccount. Make sure you Have all the following methods and data members stated

It is C++, Inherit the BankAccount class in two other classes, SavingsAccount, WalletAccount. Make sure you Have all the following methods and data members stated bellow in each class. Remember during developing, you should not be rewriting any part of the code. You should call the methods already existing in the father class as part of the new method

I already comment what need to do in code;

setdate

image text in transcribed

-------------BankAccount.h

#ifndef BANKACCOUNT_H #define BANKACCOUNT_H #include #include using namespace std; class BankAccount { public: BankAccount(); //Balance, InterestRate and LastInterestDate to 0 BankAccount(double balances, double interestRates);//Set balance and interestRate to given arguments // Set lastInterestDate to today void setBalance(double balances);//set balance to be equal to the given argument void deposit(double addition); //add the amount of the addition to the balance void withdraw(double deduction); //if the balance is enough, deduct the amount of argument form the balance // if the balance is not enough, show the message that indicated the issue void setInterestRate(double interestRates); //set the interestRate to be equal to the given argument void addInterest(); //if today lastInterestDate is more than 30 days, calculate the interest and add it the balance, also update the lastInterestDate to today double getBalance();// return the balance double getInterestRate(); // return the interestRate int getLastInterestDate(); // return the lastInterestDate void printInfo(); /* print information about the account Balance : $ Interest Rate : % Last Interest Date : */ protected: double balance = 0.0; double interestRate = 0.0; int lastInterestDate = 0; };

#endif

---------------------BankAccount.cpp

#include "BankAccount.h"

BankAccount::BankAccount() { balance = 0.0; interestRate = 0.0; lastInterestDate = 0; }

BankAccount::BankAccount(double balances, double interestRates) { balance = balances; interestRate = interestRates;

}

void BankAccount::setBalance(double balances) { balance = balances; }

void BankAccount::deposit(double addition) { balance += addition; }

void BankAccount::withdraw(double deduction) { if (deduction > balance) { cout

}

void BankAccount::setInterestRate(double interestRates) { interestRate = interestRates; }

double BankAccount::getBalance() { return balance; }

double BankAccount::getInterestRate() { return interestRate; }

int BankAccount::getLastInterestDate() { return lastInterestDate; }

void BankAccount::printInfo() { cout

#ifndef SAVINGSACCOUNT_H #define SAVINGSACCOUNT_H #include "BankAccount.h"

class SavingsAccount:public BankAccount { public: SavingsAccount(double bal, double rate, bool lock); //The same as BankAccount constructor, also update the lock data member void lockAccount(); // update the lock member to be true. Show a message that states the account is locked. void removeLock();// update the lock member to be false. Show a message that states the account is open. void setBalance(double bal); //if the account is not locked, set the balance;otherwise, show a message that states access is denied due to account being locked. void setInterestRate(double rate); // if the account is not locked, set the interest rate ,otherwise, show a message that states access is denied due to account being locked. void addInterest(); // if the account is not locked, add the interest ;otherwise, show a message that states access is denied due to account being locked. void deposit(double addition);// if the account is not locked, execute the deposit; otherwise, show a message that states access is denied due to account being locked. void withdraw(double deduction);// if the account is not locked, execute the withdrawal; otherwise, show a message that states access is denied due to account being locked. void printInfo();/* show all the account information balance : $ interest rate : % last interest date : lock : true or false */ private: bool lock = false; void accountLockMessage(); };

#endif

--------------------SavingAccount.cpp

---------------------WalletAccount.h

#ifndef WALLETACCOUNT_H #define WALLETACCOUNT_H #include "BankAccount.h" class WalletAccount:public BankAccount { public: WalletAccount(); //Should be the same as BankAccount. //Dont copy and paste code, use BankAccount constructor WalletAccount(double bal, double rate); //Should be the same as BankAccount. //Dont copy and paste code, use relative BankAccount constructor double getMaxWalletCapacity();//return maxWalletCapacity void deposit(double addition); /* if balance + addition doesnt exceed maxWalletCapacity, add the addition to the balance. Otherwise, show a message that stated the balance would exceed the wallet capacity */ void setBalance(double bal);//if bal doesnt exceed maxWalletCapacity, update the balance. Otherwise, show a me void printInfo();/* show all information about the account balance : $ interest rate : % last interest date : max wallet capacity : $ */ private: double maxWalletCapacity = 100; };

#endif --------------------------WalletAccount.cpp

#include "WalletAccount.h"

double WalletAccount::getMaxWalletCapacity() { return maxWalletCapacity; }

void WalletAccount::printInfo() { cout

//// main.cpp

#include"BankAccount.h" #include "SavingsAccount.h" #include "WalletAccount.h"

int main() { SavingsAccount saving(1000, 0.02, true); saving.printInfo(); saving.withdraw(200); saving.removeLock(); saving.withdraw(300); saving.withdraw(1000); saving.lockAccount(); saving.deposit(2000); saving.printInfo();

WalletAccount wallet(70.0, 0.02); wallet.printInfo(); wallet.deposit(50); wallet.printInfo();

}

image text in transcribed

use the following to save date as an int number #include time_t t = time(NULL); struct tm localtime_s(&now, &t); int today = (now.tm-year + 1900) * 10000 + (now.tm-mon + 1) * 100 + (now.tm-mday); * (10 point) Possible output: Account Information: Balance: $1008 Interest Rate: 2% Last Interest Date: 1/24/2019 The account is locked! Access Denied! Account is locked! The account is now open! ithdraw Denied! Not enough balance! he account is now locked! Access Denied! Account is locked! Account Information: Balance: $700 Interest Rate: 2% Last Interest Date: 1/24/2019 The account is locked! Account Information: Balance: $70 Interest Rate: 2% Last Interest Date: 1/24/2019 Max Wallet Capacity: 1ee Deposit Denied! exceeding the wallet max capacity! Account Information: Balance: $70 Interest Rate: 2% Last Interest Date: 1/24/2019 ax Wallet Capacity: 108 Hint: To reuse constructor from the base (father) class in the derived (child) class, you can use the following code: SavingsAccount: :SavingsAccount (double bal, double rate, bool lock) :BankAccount (bal, rate) this-lock lock

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions