Question: 1.Please help me debugging my program. 2. Please help me with the makefile to link them together. this is my Person.h // Create header file
1.Please help me debugging my program.
2. Please help me with the makefile to link them together.
this is my Person.h
// Create header file Person.h with #ifndef PERSON_H_ #define PERSON_H_ #include #include
using namespace std;
class Person { public: Person(); Person(int p,string nam,string sd,string ed,string par,int by,int dy); // int getPresidency(); int getBirthYear(); int getdeceasedYear(); string getname(); string getstartDate(); string getendDate(); string getParty(); private: int presidency, birthYear, deceasedYear; string name, startDate, endDate, party; };
#endif
This is my Person.cpp below
#include "Person.h" #include #include #include #include #include
using namespace std;
Person::Person() { }
Person::Person(int p,string nam,string sd,string ed,string par,int by,int dy) { presidency=p; birthYear=by; deceasedYear=dy; name=nam; startDate=sd; endDate=ed; party=par; }
//Ways to get the values
int Person::getPresidency()
{ return presidency; }
int Person::getBirthYear()
{ return birthYear; }
int Person::getdeceasedYear()
{ return deceasedYear; }
string Person::getname()
{ return name; }
string Person::getstartDate()
{ return startDate; }
string Person::getendDate()
{ return endDate; }
string Person::getParty()
{ return party; }
string trimSpace(const std::string& inStr,const std::string& spaceChar = " \t") //comment { const auto beginOfString = inStr.find_first_not_of(spaceChar); if (beginOfString == std::string::string::npos) return ""; const auto endOfString = inStr.find_last_not_of(spaceChar); const auto rangeOfString = endOfString - beginOfString + 1; return inStr.substr(beginOfString, rangeOfString);//comment }
//Ways to search by name void searchByName(vector &per) { string name; cout<<"Please enter the name: "; cin.ignore(); getline(cin,name); for(int=0;igetname(); std::size_t found = str.find(name); if (found!=std::string::npos)//comment { cout<<"Name: "<getname(); cout<<"("<getBirthYear()<<"-"; if(per.at(i)->getdeceasedYear()>0) cout<getdeceasedYear()<<")"; else cout<<"Present )"; int age; if(per.at(i)->getdeceasedYear()>0) age=per.at(i)->getdeceasedYear()-per.at(i)->getBirthYear(); else age=2017-per.at(i)->getBirthYear(); cout<<" Age: "<getPresidency(); cout<<"from"<getstartDate(); if(per.at(i)->getendDate() !="0") cout<<" to "<getendDate(); else cout<<" to present"; cout<<" Party: "<getParty()< void searchByPresidency(vector &per) { int pre; cout<<"Please enter the presidency term: "; //cin.ignore(); cin>>pre; for(int i=0;igetPresidency(); if (pre==prec) { cout<<"Name: "<getname(); if (pre==prec) { cout<<"Name: "<getname(); cout<<"("<getBirthYear()<<"-"; if(per.at(i)->getdeceasedYear()>0) cout<getdeceasedYear()<<")"; else cout<<"Present )"; int age; if (per.at(i)->getdeceasedYear()>0) age=per.at(i)->getdeceasedYear()-per.at(i)->getBirthYear(); else age=2017-per.at(i)->getBirthYear(); cout<<"Age: "<getPresidency(); cout<<" from "<getstartDate(); if(per.at(i)->getendDate()!="0") cout<<" to "<getendDate(); else cout<<" to present"; cout<<" Party: "<getParty()< &per) { string party; cout<<"Please enter the party: "; cin>>party; for(int i=0;igetParty(); if (par==party) { cout<<"Name: "<getname(); cout<<"("<getBirthYear()<<"-"; if(per.at(i)->getdeceasedYear()>0) cout<getdeceasedYear()<<")"; else cout<<"Present )"; int age; if(per.at(i)->getdeceasedYear()>0) age=per.at(i)->getdeceasedYear()-per.at(i)->getBirthYear(); else age=2017-per.at(i)->getBirthYear(); cout<<" Age: "<getPresidency(); cout<<" from "<getstartDate(); if(per.at(i)->getendDate() !="0") cout<<" to "<getendDate(); else cout<<" to present"; cout<<" Party: "<getParty()<persons; if(argc<1) { cout<<"The file should pass as comman line argument"<tokens; while(split) { string s; if(!getline(split,s,';')) break; else { string str1=trimSpace(s); token.push_back(str1); } } string pre=tokens.at(0); istringstream ss(pre); ss>>pres; nam=tokens.at(1); stddy=token.at(2); enddy=token.at(3); pty=token.at(4); string birthy=tokens.at(5); istringstream ss1(birthy); ss1>>biry; string decey=tokens.at(6); istringstream ss2(decey); ss2>>decey; Person *p=new Person(pres,nam,stddy,enddy,pty,biry,decy); persons.push_back(p); i++; } }
int ch;
//do while loop to process the inputs do { cout<<"1. Search Person's information based on name"<>ch; switch(ch) { case 1: searchByName(persons); break; case 2: SearchByPresidency(persons); break; case 3: searchByParty(persons); break; case 4: break; } } while(ch!=4); system("pause"); return 0; } This is my Printmefirst.h
#ifndef PRINTMEFIRST_H_ #define PRINTMEFIRST_H_
#include #include
void printMeFirst(std::string name,std::string courseInfor);
#endif
This is my PrintMeFirst.cpp
#include #include #include #include #include #include #include "Printmefirst.h" using namespace std;
/* Print out the programmer's information such as name, class information and dat/time when the program is run
@param name- the name of the programmer @param couselnfor- the name of the course @return- none */
void printMeFirst(string name,string courseInfor) { cout<<"Program written by:"<