H4-solutions

# Virtualdouble calcpay0 pure virtual function cis 247c

• Notes
• 8

This preview shows pages 4–7. Sign up to view the full content.

virtualdouble calcPay()=0; // pure virtual function };

This preview has intentionally blurred sections. Sign up to view the full version.

CIS-247C Homework H4 solutions 3/27/2012 //-------------------------------------------------------------- ---- // The "Employee" class //-------------------------------------------------------------- ---- class Employee : public iEmployee { private : string firstName; string lastName; char gender; int kids; double salary; staticint employees; // static member of the class Benefit benefits; // "Benefit" object as a data member public : Employee() // default constructor { firstName= "" ; lastName= "" ; gender= 'N' ; kids=0; salary=0.0; employees +=1; // increating the counter value benefits.setBenefit( "No Benefit" , 0.0, 0); } Employee(string f, string l, char g, int k, double s, string h, double li, int v) { firstName=f; lastName=l; gender=g; kids=k; salary=s; employees++; benefits.setBenefit(h, li, v); } //create the accessors and mutators for the benefit object void setFirstName(string f) { firstName=f; } void setLastName(string l) { lastName=l; } void setGender( char g) { gender=g; } void setKids( int k) { kids=k; } void setSalary( double s) { salary=s; } void setBenefits(Benefit b) { benefits=b; } string getFirstName() { return firstName; } string getLastName() { return lastName; } char getGender() { return gender; } int getKids() { return kids; } double getSalary() { return salary; } Benefit getBenefits() { return benefits; } void getEmployee() { cout<< "Employee Information\n" ;
CIS-247C Homework H4 solutions 3/27/2012 cout<< "====================================================\n" ; cout<< "Name: \t\t" <<firstName << " " <<lastName << "\n" ; cout<< "Gender:\t\t" <<gender << "\n" ; cout<< "Dependents: \t" <<kids << "\n" ; cout<< "Annual Salary:\t" <<setprecision(2)<<showpoint<<fixed<<salary << "\n" ; cout<< "Weekly Salary:\t" <<setprecision(2)<<showpoint<<fixed<<calcPay()<< "\n" ; benefits.getBenefit(); } staticint getEmployees() { return employees; } double calcPay() { return salary/52; } }; int Employee::employees=0; //initialize static data members void DisplayApplicationInformation() { cout<< "Welcome to your Object Oriented Program--Employee Class" << "CIS247C, Week 4 Lab" << "Name: Prof.Nana Liu" ; } void DisplayDivider(string message) {cout<< "\n*************** " + message + " *********************\n" ;} string GetInput( string message) { string mystring; cout<< "Please enter your " <<message << " : " ; getline(cin, mystring); return

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern