Need to implement Account.cpp and AccountManager.cpp code
//Account.hpp
#ifndef _ACCOUNT_HPP_
#define _ACCOUNT_HPP_
#include <string>
using std::string;
class Account {
public:
Account();
Account(string, double);
void deposit(double);
bool withdraw(double);
string getName() const;
double getBalance() const;
private:
string name;
double balance;
};
#endif
//////////////////////////////////////////////
//AccountManager.hpp
#ifndef _ACCOUNT_MANAGER_HPP_
#define _ACCOUNT_MANAGER_HPP_
#include "Account.hpp"
#include <string>
using std::string;
class AccountManager {
public:
AccountManager();
AccountManager(const AccountManager&); //copy constructor
void open(string);
void close(string);
void depositByName(string,double);
bool withdrawByName(string,double);
double getBalanceByName(string);
Account getAccountByName(string);
void openSuperVipAccount(Account&);
void closeSuperVipAccount();
bool getBalanceOfSuperVipAccount(double&) const;
int getAccountNumber() const;
int getManagerNumber() const;
~AccountManager();
private:
Account accountlist[100];//Record all currently open accounts
int *accountNumber;// Record the total number of currently opened
accounts
Account* SuperVipAccount; //record SuperVIP accounts, points to
NULL if an account didn' t open the SuperVIP account
static int ManagerNumber; //record total number of managers
};
#endif
/////////////////////////////////////////////////////////
//main.cpp
#include "AccountManager.hpp"
#include <iostream>
using namespace std;
int main() {
AccountManager* am = new AccountManager();
string name;
double num;
string command;
while (cin >> command) {
if (command == "open") {
cin >> name;
am -> open(name);
cout << "Account " << name << " opened." <<
endl;
}
else if (command == "deposit") {
cin >> name >> num;
am -> depositByName(name, num);
cout << name << " deposited " << num <<
endl;
num = am -> getBalanceByName(name);
cout << name << " has " << num <<
endl;
}
else if (command == "withdraw") {
cin >> name >> num;
if (am -> withdrawByName(name, num)) {
cout << name << " withdrawed " << num <<
endl;
num = am -> getBalanceByName(name);
cout << name << " has " << num <<
endl;
} else {
cout << "Withdraw failed, check the balance." <<
endl;
}
}
else if (command == "check") {
cin >> name;
num = am -> getBalanceByName(name);
cout << name << " has " << num <<
endl;
}
else if (command == "openvip") {
cin >> name;
Account ac = am -> getAccountByName(name);
if (ac.getName() == name) {
am -> openSuperVipAccount(ac);
cout << "set " << name << " as super vip"
<< endl;
} else {
cout << "no such Account" << endl;
}
}
else if (command == "closevip") {
am -> closeSuperVipAccount();
cout << "super vip closed" << endl;
}
else if (command == "quit") {
delete am;
return 0;
}
else {
cout << "No such command." << endl;
}
}
delete am;
return 0;
}
SuperVIP is existing independently, if it's close or open, the Manager's acountlist or accountNumber should not be changed.
Account.hpp
#ifndef _ACCOUNT_HPP_
#define _ACCOUNT_HPP_
#include <string>
using std::string;
class Account {
public:
Account();
Account(string, double);
void deposit(double);
bool withdraw(double);
string getName() const;
double getBalance() const;
private:
string name;
double balance;
};
#endif
Account.cpp
#include "Account.hpp"
using std::string;
Account::Account()
{
name = "";
balance = 0.0;
}
Account::Account(string name, double balance)
{
this->name = name; this->balance =
balance;
}
void Account::deposit(double amount)
{
balance += amount;
}
bool Account::withdraw(double amount)
{
if(balance < amount) return false;
balance -= amount;
return true;
}
string Account::getName() const
{
return name;
}
double Account::getBalance() const
{
return balance;
}
AccountManager.hpp
#ifndef _ACCOUNT_MANAGER_HPP_
#define _ACCOUNT_MANAGER_HPP_
#include "Account.cpp"
#include <string>
using std::string;
class AccountManager {
public:
AccountManager();
AccountManager(const AccountManager&); //copy constructor
void open(string);
void close(string);
void depositByName(string,double);
bool withdrawByName(string,double);
double getBalanceByName(string);
Account getAccountByName(string);
void openSuperVipAccount(Account&);
void closeSuperVipAccount();
bool getBalanceOfSuperVipAccount(double&) const;
int getAccountNumber() const;
static int getManagerNumber(){return ManagerNumber; }
~AccountManager();
private:
Account* accountlist[100];//Record all currently open
accounts
int *accountNumber;// Record the total number of currently opened
accounts
Account* SuperVipAccount; //record SuperVIP accounts, points to
NULL if an account didn' t open the SuperVIP account
static int ManagerNumber; //record total number of managers
};
#endif
AccountManager.cpp
#include "AccountManager.hpp"
using std::string;
AccountManager::AccountManager()
{
for(int i=0; i<100; i++) accountlist[i] =
NULL;
accountNumber = (int*)malloc(sizeof(int));
*accountNumber = 0;
SuperVipAccount = NULL; //record SuperVIP accounts,
points to NULL if an account didn' t open the SuperVIP
account
}
AccountManager::AccountManager(const AccountManager&
account)
{
}
void AccountManager::open(string name)
{
for(int i=0; i<100; i++)
if(accountlist[i]== NULL)
{
accountlist[i] =
new Account(name, 0);
*accountNumber =
*accountNumber + 1;
break;
}
}
void AccountManager::close(string name)
{
for(int i=0; i<100; i++)
if(accountlist[i]->getName()==name)
{
accountlist[i] =
NULL;
*accountNumber =
*accountNumber - 1;
break;
}
}
void AccountManager::depositByName(string name,double amount)
{
for(int i=0; i<100; i++)
if(accountlist[i]->getName()==name)
{
accountlist[i]->deposit(amount);
break;
}
}
bool AccountManager::withdrawByName(string name,double
amount)
{
for(int i=0; i<100; i++)
if(accountlist[i]->getName()==name)
{
accountlist[i]->withdraw(amount);
break;
}
}
double AccountManager::getBalanceByName(string name)
{
for(int i=0; i<100; i++)
if(accountlist[i]->getName()==name)
{
return
accountlist[i]->getBalance();
}
}
Account AccountManager::getAccountByName(string name)
{
for(int i=0; i<100 && accountlist[i]!=NULL;
i++)
if(accountlist[i]->getName()==name)
{
return
*accountlist[i];
}
Account tmp;
return tmp;
}
void AccountManager::openSuperVipAccount(Account&
account)
{
SuperVipAccount = new Account(account.getName(),
account.getBalance());
}
void AccountManager::closeSuperVipAccount()
{
if(SuperVipAccount != NULL)
delete SuperVipAccount;
SuperVipAccount = NULL;
}
bool AccountManager::getBalanceOfSuperVipAccount(double&
amount) const
{
if(SuperVipAccount == NULL) return false;
amount = SuperVipAccount->getBalance();
return true;
}
int AccountManager::getAccountNumber() const
{
return *accountNumber;
}
AccountManager::~AccountManager()
{
delete accountNumber;
if(SuperVipAccount != NULL)
delete SuperVipAccount;
}
main.cpp
#include "AccountManager.cpp"
#include <iostream>
using namespace std;
int main() {
AccountManager* am = new AccountManager();
string name;
double num;
string command;
while (cin >> command) {
if (command == "open") {
cin >> name;
am -> open(name);
cout << "Account " << name << " opened." <<
endl;
}
else if (command == "deposit") {
cin >> name >> num;
am -> depositByName(name, num);
cout << name << " deposited " << num <<
endl;
num = am -> getBalanceByName(name);
cout << name << " has " << num <<
endl;
}
else if (command == "withdraw") {
cin >> name >> num;
if (am -> withdrawByName(name, num)) {
cout << name << " withdrawed " << num <<
endl;
num = am -> getBalanceByName(name);
cout << name << " has " << num <<
endl;
} else {
cout << "Withdraw failed, check the balance." <<
endl;
}
}
else if (command == "check") {
cin >> name;
num = am -> getBalanceByName(name);
cout << name << " has " << num <<
endl;
}
else if (command == "openvip")
{
cin >> name;
Account ac = am -> getAccountByName(name);
if (ac.getName() == name)
{
am ->
openSuperVipAccount(ac);
cout << "set " << name
<< " as super vip" << endl;
}
else
{
cout << "no such Account"
<< endl;
}
}
else if (command == "closevip")
{
am -> closeSuperVipAccount();
cout << "super vip closed" << endl;
}
else if (command == "quit") {
delete am;
return 0;
}
else {
cout << "No such command." << endl;
}
}
delete am;
return 0;
}
Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #include <string> using std::string;...
In C++ ***//Cat.h//*** #ifndef __Cat_h__ #define __Cat_h__ #include <string> using namespace std; struct Cat { double length; double height; double tailLength; string eyeColour; string furClassification; //long, medium, short, none string furColours[5]; }; void initCat (Cat&, double, double, double, string, string, const string[]); void readCat (Cat&); void printCat (const Cat&); bool isCalico (const Cat&); bool isTaller (const Cat&, const Cat&); #endif ***//Cat.cpp//*** #include "Cat.h" #include <iostream> using namespace std; void initCat (Cat& cat, double l, double h, double tL, string eC,...
#ifndef PROCESSREQUESTRECORD_CLASS #define PROCESSREQUESTRECORD_CLASS #include <iostream> #include <string> using namespace std; class procReqRec { public: // default constructor procReqRec() {} // constructor procReqRec(const string& nm, int p); // access functions int getPriority(); string getName(); // update functions void setPriority(int p); void setName(const string& nm); // for maintenance of a minimum priority queue friend bool operator< (const procReqRec& left, const procReqRec& right); // output a process request record in the format // name: priority friend ostream& operator<< (ostream& ostr, const procReqRec&...
CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer; cout << "MENU" << endl; cout << "a - Add item to cart" << endl; cout << "d - Remove item from cart" << endl; cout << "c - Change item quantity" << endl; cout << "i - Output items' descriptions" << endl; cout << "o - Output shopping cart" << endl; cout << "q - Quit" << endl << endl; while (true) {...
#include <iostream> #include <string> #include "hashT.h" #include "stateData.h" using namespace std; void stateData::setStateInfo(string sName, string sCapital, double stArea, int yAdm, int oAdm) { stateName = sName; stateCapital = sCapital; stArea = stateArea; yAdm = yearOfAdmission; oAdm = orderOfAdmission; } void stateData::getStateInfo(string& sName, string& sCapital, double& stArea, int& yAdm, int& oAdm) { sName = stateName; sCapital = stateCapital; stArea = stateArea; yAdm = yearOfAdmission; oAdm = orderOfAdmission; } string stateData::getStateName() { return stateName;...
#include <iostream #include <string> #ifndef ACCOUNT H #define ACCOUNT H class Account { public: Account(std::string, int); Account(){}; void deposit(int); void withdraw(int); int getBalance() const; 15 private: int balance{@}; std::string name{}; 18 19 20 Verdif - Account.cpp saved #include "Account.h" Account :: Account(std::string accountName, int startingBalance) : name{accountName) 4 5 if (startingBalance > 0) balance = startingBalance; B 10 void Account::deposit(int depositAmount) { if (depositAmount > 0) balance + depositAmount: ) 12 13 14 15 16 void Account::withdraw(int withdrawAmount) { If...
// Name.h #ifndef __NAME_H__ #define __NAME_H__ #include <iostream> #include <string> using namespace std; #define MAXLENGTH 12 #define NAME_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-'" namespace Errors { struct InvalidName { }; } class Name { public: Name ( string first_name = "", string last_name = ""); string first() const; string last() const; void set_first( string fname ); void set_last( string lname); friend ostream& operator<< ( ostream & os, Name name ); friend bool operator== (Name name1, Name...
Help finding my errors in C++ please Header file #ifndef _FISH_SHOWER_H #define _FISH_SHOWER_H #include <iostream> #include <string> using namespace std; //NOTE: Prototypes are correct, use as a guide void WriteHeader(); void FillVectors(vector<string> &type, vector<int> &minGals, vector<int> &maxGallons); void AskFishShowerTypes(vector<string> &type, int *pIndex); void CalcPondVol(int *pGal); bool ValidateFishShower(int index, int pondVol, vector<int> &minGals, vector<int> &maxGals, vector<int> &rec); void WriteInfo(string showerType, int gallons); void WriteInfo(string showerType, vector<string> &showerTypes, vector<int> &recommendations, int gallons); #endif Main file #include "FishShower.h" using namespace std; int main()...
please help me fix the error in here #include<iostream> #include <string> using namespace std; string getStudentName(); double getNumberExams(); double getScoresAndCalculateTotal(double E); double calculateAverage(double n, double t); char determineLetterGrade(); void displayAverageGrade(); int main() { string StudentName; double NumberExam, Average, ScoresAndCalculateTotal; char LetterGrade; StudentName = getStudentName(); NumberExam = getNumberExams(); ScoresAndCalculateTotal= getScoresAndCalculateTotal(NumberExam); Average = calculateAverage(NumberExam, ScoresAndCalculateTotal); return 0; } string getStudentName() { string StudentName; cout << "\n\nEnter Student Name:"; getline(cin, StudentName); return StudentName; } double getNumberExams() { double NumberExam; cout << "\n\n Enter...
lex.h
-----------------
#ifndef LEX_H_
#define LEX_H_
#include <string>
#include <iostream>
using std::string;
using std::istream;
using std::ostream;
enum Token {
// keywords
PRINT, BEGIN, END, IF, THEN,
// an identifier
IDENT,
// an integer and string constant
ICONST, RCONST, SCONST,
// the operators, parens, semicolon
PLUS, MINUS, MULT, DIV, EQ, LPAREN, RPAREN, SCOMA, COMA,
// any error returns this token
ERR,
// when completed (EOF), return this token
DONE
};
class LexItem {
Token token;
string lexeme;
int lnum;
public:
LexItem()...