Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please provide the source code for the program below to be written in the C++ la

ID: 3854945 • Letter: P

Question

Please provide the source code for the program below to be written in the C++ language. I am new, so this is a tough example for me. Please include comments to describe what is going on in the program. And, please label which part of the code is a .cpp or .h file so I can piece it together. Thank you, and please see the following to meet requirements below:

This program will have two classes. The first class defines a person, which means this class can be used for anything that involves a person. We will use it to define a Customer but it could be used to define a Student.

Create a class called PersonData and it will have its class declaration in PersonData.h and its implementation in PersonData.cpp. This class will have private data member’s lastName, firstName, address, city, state, zip and phone number as strings. Write the appropriate accessor and mutator functions for these member variables. It should have two constructors. One constructor is a default constructor that sets all of the data members to empty strings. A second constructor has parameters for all of its data members.

Create a class called CustomerData which will have its class declaration in CustomerData.h and its implementation in CustomerData.cpp. This class will be a derived class of PersonData. This class will have two private data members for the customer number (customerNumber) as an integer; the other will be called mailingList which is a bool to indicate if they want to be on the mailing list or not. Write appropriate accessor and mutator functions for these data members. This class will also have two constructors. It will have a default constructor that sets its data members to zero and false. The other constructor will have parameters to set all of the data members of the two classes.

Create a program that will create two instances of the CustomerData class. It must create one instance using the default constructor and then another using the second constructor. Once both instances are fully populated with data, call a function that will display the customer information.

void displayCustomer(CustomerData c)

Explanation / Answer

PersonData.h

#ifndef PersonData_H

#define PersonData_H

#include <string>

class PersonData

{

private :

string lastName, firstName, address, city, state, zip, phone_number;

public :

//with default value

PersonData(const string lastName="", const string firstName="", const string address="",const string city="" ,const string state="", const string zip="" ,const string phone_number="");

// Accesor function

string getfirstname();

string getlastname();

string getaddress();

string getcity();

string getstate();

string getzip();

string getphone_number();

//Mutator function

void editfirstname(string fname);

void editlastname(string lname);

void editaddress(string add);

void editcity(string city);

void editstate(string sta);

void editzip(string zip);

void editphone_number(string number);

};

#endif

PersonData.cpp

#include <iostream>

#include <iomanip>

#include <string>

#include "PersonData.h"

using namespace std;

PersonData :: PersonData(const string lastName, const string firstName, const string address,const string city ,const string state, const string zip ,const string phone_number);

: lastName(lastName), firstName(firstName), address(address), city(city), state(state), zip(zip), phone_number(phone_number)

{}

string PersonData :: getfirstname()

{

return firstName;

}

string PersonData :: getlastname()

{

return lastName;

}

string PersonData :: getaddress()

{

return address;

}

string PersonData :: getcity()

{

return city;

}

string PersonData :: getstate()

{

return state;

}

string PersonData :: getzip()

{

return zip;

}

string PersonData :: getphone_number()

{

return phone_number;

}

void PersonData :: editfirstname(string fname)

{

firstName=fname;

}

void PersonData :: editfirstname(string fname)

{

firstName=fname;

}void PersonData :: editlastname(string lname)

{

lastName=lname;

}

void PersonData :: editaddress(string add)

{

address=add;

}

void PersonData :: editcity(string city);

{

city=city;

}

void PersonData :: editstate(string sta)

{

state=sta;

}

void PersonData :: editzip(string zip)

{

zip=zip;

}

void PersonData :: editphone_number(string number)

{

phone_number=number;

}

CustomerData.h

#ifndef CustomerData_H

#define CustomerData_H

#include PersonData.h

class CustomerData : public PersonData

{

private :

int customerNumber;

bool mailingList;

public :

//with default value

PersonData(const int customerNumber=0, const bool mailingList=false);

// Accesor functions

int getcustomerNumber();

bool getmailingList();

// mutator function

void editcustomerNumber(int custnum);

void editmailingList();

};

#endif

CustomerData.cpp

#include <iostream>

#include <iomanip>

#include "CustomerData.h"

using namespace std;

CustomerData :: CustomerData(const int customerNumber, const bool mailingList)

: customerNumber(customerNumber), mailingList(mailingList)

{}

int CustomerData :: getcustomerNumber()

{

return customerNumber;

}

bool CustomerData :: getmailingList(){

return mailingList;

}

void CustomerData :: editcustomerNumber(int custnum)

{

customerNumber=custnum;

}

void CustomerData :: editmailingList(bool mlist)

{

mailingList=mlist;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote