Question

In: Computer Science

C++ PersonData and CustomerData classes Design a class named PersonData with the following member variables: lastName...

C++

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 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 mail- ing list. Write appropriate accessor and mutator functions for these member variables. Demonstrate an object of the CustomerData class in a simple program.

Solutions

Expert Solution

#include <iostream>
using namespace std;
class PersonData
{
private:
string lastName,firstName, address, city, state,zip, phone;
public:

void setLastName(string lastName)
{
this->lastName = lastName;
}
string getLastName()
{
return lastName;
}
void setFirstName(string firstName)
{
this->firstName = firstName;
}
string getFirstName()
{
return firstName;
}
void setAddress(string address)
{
this->address = address;
}
string getAddress()
{
return address;
}
void setCity(string city)
{
this->city = city;
}
string getCity()
{
return city;
}
void setState(string state)

{
this->state = state;
}
string getState()
{
return state;
}
void setZip(string zip)
{
this->zip = zip;
}
string getZip()
{
return zip;
}
void setPhone(string phone)
{
this->phone = phone;
}
string getPhone()
{
return phone;
}
};
class CustomerData : public PersonData
{
private:
int customerNumber;
bool mailingList;
public:

void setCustomerNumber(int customerNumber)
{
this->customerNumber = customerNumber;
}
int getCustomerNumber()
{
return customerNumber;
}
void setMailingList(bool mailingList)
{
this->mailingList = mailingList;
}
int getMailingList()
{
return mailingList;
}
};
int main() {
CustomerData cust;
cust.setCustomerNumber(10);
cust.setMailingList(true);
cust.setLastName("Tom");
cust.setFirstName("Das");
cust.setAddress("34, SAS");
cust.setCity("ASD");
cust.setState("KSL");
cust.setZip("09868");
cust.setPhone("7865758789");
cout<<"Customer Number : "<<cust.getCustomerNumber();
cout<<"\nName : "<<cust.getFirstName()<<" "<<cust.getLastName();
cout<<"\nAddress : "<<cust.getAddress()<<","<<cust.getCity()<<","<<cust.getState()<<" "<<cust.getZip();
cout<<"\nPhone : "<<cust.getPhone();
return 0;
}


Related Solutions

Using C++ Design a class named PersonData with the following member variables: lastName firstName address city...
Using C++ Design a class named PersonData with the following member variables: lastName firstName address city state zip phone and at a minimum the following member functions: A class constructor - which initializes all the member variables above a display() function - which ONLY displays all the person's data to the console Also write the appropriate accessor/mutator functions for the member variables Write a NewPersonData function. This is a stand-alone function that you can use in your main to generates...
write the code in python Design a class named PersonData with the following member variables: lastName...
write the code in python 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 ....
Car Class Write a class named Car that has the following member variables: • year. An...
Car Class Write a class named Car that has the following member variables: • year. An int that holds the car’s model year. • make. A string object that holds the make of the car. • speed. An int that holds the car’s current speed. In addition, the class should have the following member functions. • Constructor. The constructor should accept the car’s year and make as arguments and assign these values to the object’s year and make member variables....
C++ Classes & Objects Create a class named Student that has three private member: string firstName...
C++ Classes & Objects Create a class named Student that has three private member: string firstName string lastName int studentID Write the required mutator and accessor methods/functions (get/set methods) to display or modify the objects. In the 'main' function do the following (1) Create a student object "student1". (2) Use set methods to assign StudentID: 6337130 firstName: Sandy lastName: Santos (3) Display the students detail using get functions in standard output using cout: Sandy Santos 6337130
/*Design and code a class Calculator that has the following * tow integer member variables, num1...
/*Design and code a class Calculator that has the following * tow integer member variables, num1 and num2. * - a method to display the sum of the two integers * - a method to display the product * - a method to display the difference * - a method to display the quotient * - a method to display the modulo (num1%num2) * - a method toString() to return num1 and num2 in a string * - Test your...
In C++ please Your class could have the following member functions and member variables. However, it's...
In C++ please Your class could have the following member functions and member variables. However, it's up to you to design the class however you like. The following is a suggestion, you can add more member variables and functions or remove any as you like, except shuffle() and printDeck(): (Note: operators must be implemented) bool empty(); //returns true if deck has no cards int cardIndex; //marks the index of the next card in the deck Card deck[52];// this is your...
Using C++ programming. Thank you. Money class has the following member variables and functions. -member variable...
Using C++ programming. Thank you. Money class has the following member variables and functions. -member variable : dollar, cent -member function : setMoney(int dollar, int cent), printMoney(), operator overloading(+) Program the Money class so that the following function can be performed. int main(){ Money a, b, c; A.setMoney(10, 60); B.setMoney(20, 70; (a+b).printMoney(); c = a + b; c.printMoney(); }
JAVA Design a class named Person and its two derived classes named Student and Employee. Make...
JAVA Design a class named Person and its two derived classes named Student and Employee. Make Faculty and Staff derived classes of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). An employee has an office, salary, and datehired. Define a class named MyDate that contains the fields year, month, and day. A faculty member has office hours and a rank. A staff member has a...
c++ E2b: Design a class named Rectangle to represent a rectangle. The class contains:
using c++E2b: Design a class named Rectangle to represent a rectangle. The class contains:(1) Two double data members named width and height which specifies the width and height of the rectangle .(2) A no-arg constructor that creates a rectangle with width 1 and height 1.(3) A constructor that creates a rectangle with the specified width and height .(4) A function named getArea() that returns the area of this rectangle .(5) A function named getPerimeter() that returns the perimeter of this...
Complete the following C++ tasks: a. Design a class named BaseballGame that has fields for two...
Complete the following C++ tasks: a. Design a class named BaseballGame that has fields for two team names and a final score for each team. Include methods to set and get the values for each data field. Create the class diagram and write the pseudocode that defines the class. b. Design an application that declares three BaseballGame objects and sets and displays their values. c. Design an application that declares an array of 12 BaseballGame objects. Prompt the user for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT