Question: home / study / engineering / computer science / questions and answers / design a class named persondata with the following ... Question: Design a
home / study / engineering / computer science / questions and answers / design a class named persondata with the following ...
Question: Design a class named PersonData with the following...
Bookmark
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 integer 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. demonstarate an object of the customerdata class in a simple program
*************please help- what am I doing wrong - thanks c++
#include
using namespace std;
class PersonData { private: string lastname; string firstname; string address; string city; string State; int zip; int phonenumber; public: void setlastname(string l) { lastname = l; } void setfirstname(string f) { firstname = f; } void setaddress(string a) { address = a; } void setcity(string c) { city = c; } void setState(string S) { State = S; } void setzip(int z) { zip = z; } void setphonenumber(int p) { phonenumber = p; } string getlastname() { return lastname; } string getfirstname() { return firstname; } string getaddress() { return address; } string getcity() { return city; } string getState() { return State; } int getzip() { return zip; } int getphonenumber() { return phonenumber; }
}; class Customerclass: public PersonData { private: int customernumber; bool mailinglist; public: void setcustomernumber(int ); void setmailinglist(bool ); int getcustomernumber();
}; void Customerclass::setcustomernumber(int customer) { customernumber = customer; cout << "Enter the a member Id: Example 7654357 " << endl; cin >> customer;
} void Customerclass::setmailinglist(bool Mail) { mailinglist = Mail; string yesorno;
cout << "Would you like to be on the Mailing list? Enter (Yes or No:)" << endl; cin >> yesorno; if(yesorno == "Yes" || yesorno == "yes") { cout << "You are part of the mailing list: " << endl; Mail = true; } else { cout << "You don't want to be part of the Mailing list: " << endl; Mail = false;
}
} int Customerclass::getcustomernumber() { return customernumber; }
int main() {
Customerclass Y; string LASTNAME; string FIRSTNAME; string ADDRESS; string CITY; string STATE; int ZIP; int PHONE; int CustomerID; bool trueorfalse;
Y.setmailinglist(trueorfalse);
cout << "Enter Lastname: " << endl; getline(cin, LASTNAME); cin.ignore(); cout<< "Enter Firstname: " << endl; getline(cin, FIRSTNAME); cin.ignore(); cout << "Enter Address: " << endl; getline(cin, ADDRESS); cin.ignore(); cout << "Enter City: " << endl; getline(cin, CITY); cin.ignore(); cout << "Enter State: " << endl; getline(cin, STATE); cin.ignore(); cout << "Enter Zip code: " << endl; cin >> ZIP; cout << "Enter Phone number: " << endl; cin >> PHONE; Y.setlastname(LASTNAME); Y.setfirstname(FIRSTNAME); Y.setaddress(ADDRESS); Y.setcity(CITY); Y.setState(STATE); Y.setzip(ZIP); Y.setphonenumber(PHONE); Y.setcustomernumber(CustomerID); cout << "Customer ID: " << Y.getcustomernumber() << endl; cout << "First and last name: " << Y.getfirstname() << " " << Y.getlastname() << endl; cout << "Address: " << Y.getaddress() << " " << Y.getcity() << " " << Y.getState() << " " << Y.getzip() << endl; cout << "Phone number: " << Y.getphonenumber() << endl;
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
