extPersonType::extPersonType(string a, string b, int c, int d, int e, string f,
string g, string h, long i, long j, string k)
: personType(a,b), dateType(c,d,e), addressType(f,g,h,i)
{
phoneNo = j;
memT = k;
}
void loadData();
void sortAddressBook();
short searchPerson(string);
bool searchFunction(string, string);
void printAPB();
void nameBPeople();
bool dBirthFunction(short, short, short, short, short, short, short);
void printBName();
void printRName();
void userRequestName();
int main()
{
loadData(); //Here is some error I think but I m not sure
cout<<"***Sample of loadData function***"<<endl;
addressBook[0].print();
sortAddressBook();
cout<<"***Sample sortAddressBook function***"<<endl;
for(short i=0; i<2; i++)
addressBook[i].print();
cout<<"**************************************"<<endl;
string a;
cout<<"Please enter the last name of the person"<<endl
<<"you are looking for: ";
cin>>a;
if(searchPerson(a))
cout<<"Search person not found."<<endl;
else
{
cout<<"Person found"<<endl;
addressBook[searchPerson(a)].print();
}
printAPB();
cout<<"***Search people by birthday***"<<endl;
nameBPeople();
cout<<"***Print names between two last names***"<<endl;
printBName();
cout<<"***User request names***"<<endl;
userRequestName();
system("pause");
return 0;
}
void loadData()
{
string a,b,f,g,h,k;
int c,d,e;
long i,j;
ifstream inPut("addressBook.txt");
if(inPut.is_open())
{
cout<<"File opened"<<endl;
short l=0;
while(!inPut.eof())
{
inPut>>a>>b>>c>>d
>>e>>f>>g>>h
>>i>>j>>k;
addressBook[l].setName(a,b);
addressBook[l].setDate(c,d,e);
addressBook[l].setAddr(f,g,h,i);
addressBook[l].setPhNo(j);
addressBook[l].setMemT(k);
l++;
}
inPut.close();
}
else
{
cout<<"File addressBook.txt not found."<<endl
<<"Program will terminate now"<<endl;
}
}
void printAPB()
{
string a;
cout<<"Enter the last name of the person"<<endl
<<"whose address, phone and date of "<<endl
<<"birth is required: ";
cin>>a;
if(!searchPerson(a)==0)
cout<<"Information about required person"<<endl
<<"not found"<<endl;
else
{
addressBook[searchPerson(a)].printAdd();
addressBook[searchPerson(a)].printPhNo();
addressBook[searchPerson(a)].printDate();
}
}
void nameBPeople()
{
short m1,d1,y1,m2,d2,y2;
cout<<"Enter first month, day and year: ";
cin>>m1>>d1>>y1;
cout<<"Enter second month, day and year: ";
cin>>m2>>d2>>y2;
for(short i=0; i<3; i++)
if(dBirthFunction(m1,d1,y1,m2,d2,y2,i))
addressBook[i].print();
}
bool dBirthFunction(short m1, short d1, short y1, short m2,
short d2, short y2, short i)
{
int m,d,y;
addressBook[i].getDate(m,d,y);
if(m>m1 && m<m2 && d>d1 && d<d2 && y>y1 && y<y2)
return 1;
else
return 0;
}
void printBName()
{
string ist, second, temp, a;
cout<<"Enter the first last name: ";
cin>>ist;
cout<<"Enter the second last name: ";
cin>>second;
if(static_cast<int>(ist[0]) > static_cast<int>(second[0]))
{
temp = ist;
ist = second;
second = temp;
}
bool start = 0;
for(short i=0; i<3; i++)
{
addressBook[i].getName(a, temp);
if(searchFunction(temp, ist) || start)
{
if(!start)
start =1;
addressBook[i].print();
if(searchFunction(temp, second))
start = 0;
}
}
}