#ifndef EMPLOYEE_H #define EMPLOYEE_H #include #include #include #include using namespace std; #define FEDTAXRATE 0.15 #define STATETAXRATE 0.07 #define SSITAXRATE 0.0775 #define MAX 5 class Employee { private: char *lname; char *fname; float deffered; float gross; float net; float fedTax; float stateTax; float ssiTax; float calcFed(void) {return (gross-deffered)*FEDTAXRATE;} float calcState(void){return (fedTax * STATETAXRATE);} float calcSSI(void){return (gross-deffered)*SSITAXRATE;} public: Employee(const char*last="",const char* first="",float deff=0.0) :lname(NULL), fname(NULL),deffered(deff),gross(0), net(0), fedTax(0), stateTax(0), ssiTax(0) { int len = strlen(last); lname = new char[len+1]; strcpy(lname, last); len = strlen(first); fname = new char[len+1]; strcpy(fname, first); } ~Employee()//destruct { delete [] fname; delete [] lname; } char* getLastName(void)const{return this->lname;} char* getFirstName(void)const{return fname;} char* Employee::getFullName(void); const float getDeffered(void)const{return deffered;} const float getGross(void)const{return gross;} const float getNet(void)const{return net;} const float getFedTax(void)const{return fedTax;} const float getStateTax(void)const{return stateTax;} const float getSSITax(void)const{return ssiTax;} void setLastName(const char * last){ int len =strlen(last);lname = new char[len+1];strcpy(lname, last);} void setFirstName(const char * first){int len =strlen(first);fname = new char[len+1];strcpy(fname, first);} void setDeffered(const float def){deffered=def;} void setGross(const float f){gross=f;} void calcNet(void); virtual void calcGross()=0; virtual int GetType() const = 0; virtual void printTitle(FILE* r) =0; virtual void printSubTotal(FILE* r)=0; }; void Employee::calcNet(void) { if(this->getGross()>0) { // protect the data this->fedTax = calcFed(); this->stateTax = calcState(); this->ssiTax = calcSSI(); this->net = gross-(fedTax+stateTax+ssiTax+deffered); } else { cout<<"\nGross is less than Zero";} } char* Employee::getFullName(void) { char* fullName=new char[20+1]; strcpy(fullName,getLastName());// for formatting name to report spec strcat(fullName,", ");//add comma space strcat(fullName,getFirstName()); int l = strlen(fullName); while(l<20) // this loops pads the employees name { fullName[l] = ' '; // insert a space l++; } fullName[l]= '\0'; // strings need to be terminated in a null return fullName; } #endif