3 CheckingAccount class Change to a template class. Add accountNumber to the con
ID: 3914713 • Letter: 3
Question
3 CheckingAccount class
Change to a template class. Add accountNumber to the constructor. No other modifications.
//
// checkingaccount.cpp
// Homework 3
//
// Created by ines said on 6/20/18.
// Copyright © 2018 ines said. All rights reserved.
//
#include "checkingaccount.h"
void CheckingAccount::debit(double amount){
account::debit(amount); // withdraws ammount
account::debit(feeForTransaction); // withdraws trasation fee
}
void CheckingAccount::credit(double amount){
account::credit(amount); // adds amount
account::debit(feeForTransaction); // calculate transaction fee
}
double CheckingAccount::getFeeForTransaction(){
return feeForTransaction; // return the transaction fee
}
//
// checkingaccount.hpp
// Homework 3
//
// Created by ines said on 6/20/18.
// Copyright © 2018 ines said. All rights reserved.
//
#ifndef checkingaccount_h
#define checkingaccount_h
#include<iostream>
#include "account.h"
using namespace std;
class CheckingAccount:public account{
public: // public data members
CheckingAccount() : account(){
feeForTransaction = 0;
}
CheckingAccount(double bal, double fee) : account(bal){
if (fee > 0) // check if the fee for transaction is more than 0
{
feeForTransaction = fee;} // assign it to the value
else // if fee is nore more than 0 print error message and assign 0 to it
{
cout << "error Fee for transaction is smaller than 0" << endl;
feeForTransaction = 0;
}
}
// destrcutor definition
~CheckingAccount(){
}
virtual void credit(double amount); // declare virtual function credit
virtual void debit(double amount); // declare victural function debit
double getFeeForTransaction();
private: // private data members
double feeForTransaction;
};
#endif
Explanation / Answer
/
// checkingaccount.cpp
// Homework 3
//
// Created by ines said on 6/20/18.
// Copyright © 2018 ines said. All rights reserved.
//
#include "checkingaccount.h"
void CheckingAccount::debit(double amount){
account::debit(amount); // withdraws ammount
account::debit(feeForTransaction); // withdraws trasation fee
}
void CheckingAccount::credit(double amount){
account::credit(amount); // adds amount
account::debit(feeForTransaction); // calculate transaction fee
}
double CheckingAccount::getFeeForTransaction(){
return feeForTransaction; // return the transaction fee
}
//
// checkingaccount.hpp
// Homework 3
//
// Created by ines said on 6/20/18.
// Copyright © 2018 ines said. All rights reserved.
//
#ifndef checkingaccount_h
#define checkingaccount_h
#include<iostream>
#include "account.h"
using namespace std;
class CheckingAccount:public account{
public: // public data members
long int addAccountNumber;
CheckingAccount() : account(){
feeForTransaction = 0;
addAccountNumber=0;
}
CheckingAccount(double bal, double fee) : account(bal){
if (fee > 0) // check if the fee for transaction is more than 0
{
feeForTransaction = fee;} // assign it to the value
else // if fee is nore more than 0 print error message and assign 0 to it
{
cout << "error Fee for transaction is smaller than 0" << endl;
feeForTransaction = 0;
}
}
// destrcutor definition
~CheckingAccount(){
}
virtual void credit(double amount); // declare virtual function credit
virtual void debit(double amount); // declare victural function debit
double getFeeForTransaction();
private: // private data members
double feeForTransaction;
};
#endif
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.