Please Help must have . h for each class and must have .cpp for each class must
ID: 3917324 • Letter: P
Question
Please Help
must have . h for each class
and must have .cpp for each class
must have a .cpp for mutators and functions
and must have .cpp for main as well
Im very lost please help
every time i try anyway i get a ton of errors or im forced to use /FORCE to run which he does not want
Design a class named PersonData with the following member variables: ? lastName ? firstName ? address ? city ? state ? zip ? phone Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData, which is derived from the PersonData class. The CustomerData class should have the following member variables: ? customerNumber ? mailingList The customerNumber variable will be used to hold a unique string for each customer. The mailingList variable should be a bool. It will be set to true if the customer wishes to be on a mailing list, or false if the customer does not wish to be on a mailing list. Write appropriate accessor and mutator functions for these member variables. Demonstrate an object of the CustomerData class in a simple program
PersonData and CustomerData classes
Design a class named PersonData with the following member variables:
lastName
firstName
address
city
state
zip
phone
Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData, which is derived from the PersonData class.
The CustomerData class should have the following member variables:
customerNumber
mailingList
The customerNumber variable will be used to hold a unique string for each customer. The mailingList variable should be a bool. It will be set to true if the customer wishes to be on a mailing list, or false if the customer does not wish to be on a mailing list. Write appropriate accessor and mutator functions for these member variables.
Demonstrate an object of the CustomerData class in a simple program.
Explanation / Answer
//Unable to see target output image (Password protected)
//.cpp and .h files each for PersonData and CustomerData
//One main.cpp that creates object of CustomerData and takes user input to initialize values
//Place all 5 files in one new folder and run using the following command on terminal ->
//g++ *.cpp
-------------------------------------------------------------
//PersonData.h
#ifndef PersonData_H
#define PersonData_H
#include <string>
using namespace std;
class PersonData {
private:
string lastName;
string firstName;
string address;
string city;
string state;
int zip;
int phone;
public:
string getLastName() ;
string getFirstName() ;
string getAddress() ;
string getCity() ;
string getState() ;
int getZip() ;
int getPhone() ;
void setLastName(string newLastName) ;
void setFirstName(string newFirstName) ;
void setAddress(string newAddress) ;
void setCity(string newCity) ;
void setState(string newState) ;
void setZip(int newZip) ;
void setPhone(int newPhone) ;
};
#endif
-------------------------------------------------------
//PersonData.cpp
#include "PersonData.h"
string PersonData::getLastName() {return lastName;} ;
string PersonData::getFirstName() {return firstName;} ;
string PersonData::getAddress() {return address;} ;
string PersonData::getCity() {return city;} ;
string PersonData::getState() {return state;} ;
int PersonData::getZip() {return zip;} ;
int PersonData::getPhone() {return phone;} ;
void PersonData::setLastName(string newLastName) { lastName=newLastName;} ;
void PersonData::setFirstName(string newFirstName) { firstName=newFirstName;} ;
void PersonData::setAddress(string newAddress) { address=newAddress;} ;
void PersonData::setCity(string newCity) { city=newCity;} ;
void PersonData::setState(string newState) { state=newState;} ;
void PersonData::setZip(int newZip) {zip=newZip;};
void PersonData::setPhone(int newPhone) {zip=newPhone;};
------------------------------------------------
//CustomerData.h
#ifndef CustomerData_H
#define CustomerData_H
#include <string>
#include "PersonData.h"
class CustomerData : public PersonData {
private:
std::string customerNumber;
bool mailingList;
public:
std::string getCustomerNumber();
bool getMailingList();
void setCustomerNumber(string newCustomerNumber);
void setMailingList(int newMailingList);
};
#endif
-------------------------------------------------
//CustomerData.cpp
#include "CustomerData.h"
string CustomerData::getCustomerNumber() {return customerNumber;} ;
bool CustomerData::getMailingList() {return mailingList;} ;
void CustomerData::setCustomerNumber(string newCustomerNumber) { customerNumber=newCustomerNumber; } ;
void CustomerData::setMailingList(int newMailingList) { mailingList=newMailingList; } ;
------------------------------------------------
//main.cpp
#include <iostream>
#include <string>
#include "PersonData.h"
#include "CustomerData.h"
using namespace std;
int main() {
CustomerData cust1;
string lastName;
string firstName;
string city;
int phone;
cout << "Enter customer last name ";
cin >> lastName;
cust1.setLastName(lastName);
cout << "Enter customer first name ";
cin >> firstName;
cust1.setFirstName(firstName);
cout << "Enter customer city ";
cin >> city;
cust1.setCity(city);
cout << "Enter customer phone number ";
cin >> phone;
cust1.setPhone(phone);
string customerNumber = lastName+":"+firstName+":"+to_string(phone);
cout << "Enter 0 if you do not want to be added to the mailing list, otherwise enter 1 ";
cust1.setCustomerNumber(customerNumber);
int option;
cin >> option;
bool mailingList;
if(option) mailingList = true;
else mailingList = false;
cust1.setMailingList(mailingList);
return 0;
}
---------------------------------------------------------