Question
PLEASE I NEED HELP modifying this Vector address book program by creating a Person Class, an Employer Class and a Personal Info Class. Using the
PLEASE I NEED HELP modifying this Vector address book program by creating a Person Class, an Employer Class and a Personal Info Class. Using the Employer and Personal Info classes as member variables of a Person class. Modify the Vector class to hold People objects instead of Record objects. Modify the menu interface and input algorithms to accept data for the Employer and Personal Info classes via functions in the Person class. Modify the Output to print all the information in each Person object, associated Employer object, and associated Personal Info object.
addressBook.cpp
#include
#include
#include
#include
#include "addressBook.h"
using namespace std;
int main()
{
vector
int counter = 0;
std::string fname, lname;
int age, op = 0;
long int phoneNum;
while (1)
{
cout << "1.Enter info 2.Display info 3.Exit ";
cin >> op;
switch (op)
{
case 1:
{
cout << "First Name :";
cin >> fname;
cout << "Last Name :";
cin >> lname;
cout << "Age :";
cin >> age;
cout << "Phone Number :";
cin >> phoneNum;
AddressBook temp_addr;
temp_addr.setFname(fname);
temp_addr.setLname(lname);
temp_addr.setAge(age);
temp_addr.setTelNum(phoneNum);
addressBook.push_back(temp_addr);
counter++;
}
break;
case 2:
for (int i = 0; i < counter; i++)
{
cout << addressBook[i].getFname();
cout << " " << addressBook[i].getLname();
cout << " " << addressBook[i].getAge();
cout << " " << addressBook[i].getTelNum();
cout << endl;
}
break;
case 3:
exit(1);
break;
}
}
}
addressBook.h
#include
using namespace std;
class AddressBook
{
private:
string fname;
string lname;
int age;
long int phoneNum;
public:
void setFname(string fname)
{
this->fname = fname;
}
void setLname(string lname)
{
this->lname = lname;
}
void setAge(int age)
{
this->age = age;
}
void setTelNum(long int phoneNum)
{
this->phoneNum = phoneNum;
}
string getFname()
{
return fname;
}
string getLname()
{
return lname;
}
int getAge()
{
return age;
}
long int getTelNum()
{
return phoneNum;
}
};
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started