Hello I write down a bank program and I have a problem. I would be happy if you can help me.
So I have two types of accounts each account in a different class. first one is limited account and yhe secound is over draft account also I have class of original bank account.
I get the user name and what type of account it should and after that I need to create the necessary account.
The problem I encounter is to create the required account. I create a standard account and then I have to create the account thet the user wants but I not figure out how to do it.
I would be happy if you could help me understand how to create the additional account thet the user requests.
Bank main-
#include "BankAccount.h"
#include "LimitedBankAccount.h"
#include "OverDraftAccount.h"
using namespace std;
int main()
{
int choice = 0, accounts = 0;
string name;
string account;
while (choice != 4)
{
cout << "Welcome to Bank," << endl;
cout << "1. to add new account" << endl;
cout << "4. to exit" << endl;
cin >> choice;
BankAccount node(NULL);
LimitedBankAccount a(NULL);
if(choice == 1)
{
if(accounts > 1000)
{
cout << "You have 1000 account try at another time" << endl;
exit(0);
}
else
{
cout << "Enter type of account to create: " << endl;
cin >> account;
cout << "Enter name for the account: " << endl;
cin >> name;
if(account == "limited account")
{
node.NewBankAccount(name);
// here need to be create the LimitedBankAccount
}
else
{
}
}
}
}
return 0;
}
bank account .h -
#ifndef BANKACCOUNT_H
#define BANKACCOUNT_H
#include <iostream>
#include <stdio.h>
#include <string>
class BankAccount{
public:
BankAccount(std::string name);
std::string getNmae();
double getBalance();
void NewBankAccount(std::string name);
protected:
bank account cpp-
#include "BankAccount.h"
BankAccount::BankAccount(std::string name)
{
_name = name;
_balance = 0;
}
std::string BankAccount::getNmae()
{
return _name;
}
double BankAccount::getBalance()
{
return _balance;
}
std::string _name;
double _balance;
private:
BankAccount* _bank;
};
#endif
Limited Account .h -
#ifndef LIMITEDBANKACCOUNT_H
#define LIMITEDBANKACCOUNT_H
#include <iostream>
#include <string>
#include "BankAccount.h"
class LimitedBankAccount : public BankAccount{
public:
LimitedBankAccount(double limit);
double getLimit();
void NewLimitedAccount();
protected:
private:
double _limit;
LimitedBankAccount* node;
};
#endif
Limited Account cpp -
#include "LimitedBankAccount.h"
LimitedBankAccount::LimitedBankAccount(double limit) : BankAccount(_name)
{
_limit = limit;
}
void LimitedBankAccount::setLimit(double num)
{
_limit = num;
}
double LimitedBankAccount::getLimit()
{
return _limit;
}
Over Draft Account .h -
#ifndef OVERDRAFTACCOUNT_H
#define OVERDRAFTACCOUNT_H
#include <iostream>
#include <string>
#include "BankAccount.h"
class OverDraftAccount : BankAccount{
public:
OverDraftAccount(double max);
double getMax();
protected:
private:
double _maxOverDraft;
OverDraftAccount* node;
};
#endif
Over Draft Account .cpp -
#include "OverDraftAccount.h"
OverDraftAccount::OverDraftAccount(double max) : BankAccount(_name)
{
_maxOverDraft = max;
}
double OverDraftAccount::getMax()
{
return _maxOverDraft;
}
Thank you to all who help !!!