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

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...
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...
Write a C++ program (The Account Class) Design a class named Account that contains (keep the...
Write a C++ program (The Account Class) Design a class named Account that contains (keep the data fields private): a) An int data field named id for the account. b) A double data field named balance for the account. c) A double data field named annualInterestRate that stores the current interest rate. d) A no-arg constructor that creates a default account with id 0, balance 0, and annualInterestRate 0. e) The accessor and mutator functions for id, balance, and annualInterestRate....
In c++ Design a class named Account that contains: a.An int data field named id for...
In c++ Design a class named Account that contains: a.An int data field named id for the account. b.A double data field named balancefor the account. c.A double data field named annualInterestRate that stores the current interestrate. d.A no-arg constructor that creates a default account with id 0, balance 0, andannualInterestRate 0. e.The set and get functions for id,balance, and annualInterestRate. f.A functionearnedAmount()that calculates and returns the amount of dollars earned after one year. g.A function named printAccountInfo() that print...
directions: use c++ Create a  ContactInfo class that contains the following member variables: name age phoneNumber The...
directions: use c++ Create a  ContactInfo class that contains the following member variables: name age phoneNumber The ContactInfo class should have a default constructor that sets name = "", phoneNumber = "", and age = 0. The ContactInfo class should have a constructor that accepts the name and phone number as parameters and sets name = <value of parameter name>, aAge = 0, and phoneNumber = <value of parameter phone number>. The ContactInfo class should have accessor and mutator functions for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT