I need some help with the following code. I want this to be the input data: This
ID: 3655556 • Letter: I
Question
I need some help with the following code.
I want this to be the input data:
This has to do with Classes and the Project is broken up into three files: Implementation, MainLine and Header File. If you have Bloodshed, this is what it's suppose to look like:
Here's my code:
Header File:
#ifndef MEMBERTYPE_H
#define MEMBERTYPE_H
#include<iostream>
#include<string>
using namespace std;
class memberType{
string memberID;
string firstName;
string lastName;
int booksPurchased;
double amountSpent;
public:
//prototype
memberType();
memberType(string ID, string fName, string lName,int bPurchased, double amount);
//mutators
void setMemberInfo(string ID, string fName, string lName,int bPurchased, double amount);
void setMemberID(string);
void setName(string, string);
//accessor
bool isMemberID(string) const;
int getBooksPurchased() const;
double getTotalAmountSpent() const;
//fxn, methods
void purchaseBook(double amount);
void resetbooksBoughtAndAmount();
void printMemberID() const;
void printName() const;
void printInfo() const;
};//end of class
#endif
Implementation File:
#include<iostream>
#include<string>
#include"memberType.h"
using namespace std;
memberType::memberType(){
memberID="0";
firstName="First";
lastName="Last";
booksPurchased=0;
amountSpent=0;
}
memberType::memberType(string ID, string fName, string lName,int bPurchased, double amount){
memberID=ID;
firstName=fName;
lastName=lName;
booksPurchased=bPurchased;
amountSpent=amount;
}
//mutators
void memberType::setMemberInfo(string ID, string fName, string lName,int bPurchased, double amount){
memberID=ID;
firstName=fName;
lastName=lName;
booksPurchased=bPurchased;
amountSpent=amount;
}
void memberType::setMemberID(string ID){memberID=ID;}
void memberType::setName(string fName, string lName){firstName=fName; lastName=lName;}
bool memberType::isMemberID(string ID) const{
return(memberID==ID); //returns 1 for true, 0 for false
}
//accessor
int memberType::getBooksPurchased() const{return booksPurchased;}
double memberType::getTotalAmountSpent() const{return amountSpent;}
//fxn, methods
void memberType::purchaseBook(double amount){
booksPurchased++;//add 1
amountSpent+=amount; //add amount to amountSpent
}
void memberType::resetbooksBoughtAndAmount(){//initializes booksPurchased and amountSpent to zero.
booksPurchased=0;
amountSpent=0;
}
void memberType::printMemberID() const{
cout<<memberID;
}
void memberType::printName() const{
cout<<firstName<<" "<<lastName;
return;
}
void memberType::printInfo() const{
cout<<" Member ID: ";
printMemberID();
cout<<" Name: ";
printName();
cout<<" Number of Books Bought: "<<booksPurchased;
cout<<" Total Amount Spent: $"<<amountSpent<<endl;
return;
}