Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Ok, I tried doing this one and am out of time (again) to turn it in :( Heres the

ID: 3633710 • Letter: O

Question

Ok, I tried doing this one and am out of time (again) to turn it in :(

Heres the project:

The only change to the Employee class is that there is a new attribute:

+benefit : Benefit

Notice that there is a "+" for this attribute, meaning that it is public. Make sure to examine the multi-arg constructor's signature!

The dotted directed line between Employee and iEmployee specifies that the Employee class must implement the iEmployee abstract class, and thus provide an implementation for the calculatePay method.

STEP 1: Create the Project

We use the prior code from week 3

That Code is Here:

---------------------------------------------------------------------------------------------------------
#include
#include

#include

#include

using namespace std;

class Employee

{

private:

//Private members class Employee

string firstName;

string lastName;

string gender;

int dependents;

double salary;

static int numEmployees;

public:

//Public member functions class Employee

//default constructors

Employee()

{

firstName="Not-Given";

lastName="Not-Given";

gender="U";

dependents=0;

salary=20000;

numEmployees +=1;

}

//specific constructor

Employee(string firstName,string lastName,

string gender,int dependents,double salary)

{

numEmployees +=1;

this->firstName =firstName;

this->lastName =lastName;

this->gender =gender;

this->dependents =dependents;

this->salary =salary;

}

//prompts user to enter Employee data

void getData()

{

cout<<"Enter firstName ";

cin>>firstName;

setFirstName(firstName);

cout<<"Enter lastName ";

cin>>lastName;

setLastName(lastName);

cout<<"Enter Gender ";

cin>>gender;

setGender(gender);

cout<<"Enter Dependents ";

cin>>dependents;

setDependents(dependents);

cout<<"Enter Salary ";

cin>>salary;

setAnnualSalary(salary);

}

//setter methods

void setFirstName(string firstName)

{

this->firstName=firstName;

}

void setLastName(string lastName)

{

this->lastName =lastName;

}

void setGender(string gender)

{

this->gender =gender;

}

void setDependents(int dependents)

{

this->dependents =dependents;

}

void setAnnualSalary(double salary)

{

this->salary =salary;

}

//getter methods

string getFirstName()

{

return firstName;

}

string getLastName()

{

return lastName;

}

string getGender()

{

return gender;

}

int getDependents()

{

return dependents;

}

double getAnnualSalary()

{

return salary;

}

//calculattions

double calculatePay()

{

return getAnnualSalary()/52;

}

void display()

{

displayDivider();

cout<
cout<
cout<
cout<
cout<
"AnnualSalary :"<
cout<
"Weekly Pay:" <
}

//Heading for Employee Information

void displayDivider()

{

cout<<" EMPLOYEE INFORMATION"<
cout<<"****************************************"<
}

static int getNumEmployees()

{

return numEmployees;

}

};

int Employee::numEmployees=0;

int main()

{

//Employee object

//Prompt user to enter Employee data

Employee obj;

//call getData

obj.getData();

obj.display ();

//parameterized constructor

Employee obj2("Mary", "Noia", "F", 5, 24000.0);

obj2.display();

int numEmp=Employee::getNumEmployees();

cout<<"Number of employees :"< cout<<"This is the End of The CIS247C Week 3 Lab"<<

system("pause");
return 0;
}

---------------------------------------------------------------------------------------------------------



STEP 2: Modify the Employee Class


Using the UML Diagrams from Step 1, create the Benefit class. To get an idea of how to format displayBenefits, take a look at the output in Step 5.

Add a Benefit attribute to the Employee class.

Initialize the new Benefit attribute in both Employee constructors. Again, take note of the multi-arg constructors parameter list!

Create the iEmployee interface (abstract class in C++).

Modify the Employee class to implement the new interface so that Employee will have to implement the calculatePay method.

class Employee : public iEmployee

Modify the Employee class to call displayBenefit when displaying Employee information.

STEP 4: Modify the Main Method


Notice that the Employee class now has a public benefit object inside it. This means that you can access the set methods of the Benefit object with the following code:

.benefit.



As an example, to set the lifeInsurance attribute inside an Employee object called emp, we could execute the following code:

emp.benefit.setLifeInsurance(lifeInsurance);

The steps required to modify the Main class are below. New steps are in bold.

Create an Employee object using the default constructor.

Prompt for and then set the first name, last name, and gender. Consider using your getInput method from Week 1 to obtain data from the user for this step as well as Step 3.

Prompt for and then set the dependents and annual salary using the overloaded setters that accept Strings.

Prompt for and set healthInsurance, lifeInsurance, and vacation.

Using your code from Week 1, display a divider that contains the string "Employee Information".

Display the Employee Information.

Display the number of employees created using getNumEmployees(). Remember to access getNumEmployees using the class name, not the Employee object.

Create a Benefit object called benefit1 using the multi-arg construction. Use any information you want for health insurance, life insurance, and vacation.

Create another Employee object and use the constructor to fill it with the following:

"Mary", "Noia", 'F', 5, 24000.0, benefit1

Using your code from Week 1, display a divider that contains the string "Employee Information".

Display the employee information.

Display the number of employees created using getNumEmployees(). Remember to access getNumEmployees using the class name, not the Employee object.

The UML is here:






Any help whatsoever is appreciated! I am taking 4 classes and this one is just so difficult I keep getting stuck :(

(note: our professor only gives 100% credit on "working programs" ..if it does not work, its a 0 ) So its pass or fail each week which I do not think creates a healthy learning environment, but anyway...

Thank you in advance, you people are wonderful here :)

Explanation / Answer

I have had recently two telephone interviews where I've been asked about the differences between an Interface and an Abstract class. I have explained every aspect of them I could think of, but it seems they are waiting for me to mention something specific, and I dont know what it is. From my experience I think the following is true, if i am missing a major point please let me know: Interface: Every single Method declared in an Interface will have to be implemented in the subclass. Only Events, Delegates, Properties (C#) and Methods can exist in a Interface. A class can implement multiple Interfaces. Abstract Class Only Abstract methods have to be implemented by the subclass. An Abstract class can have normal methods with implementations. Abstract class can also have class variables beside Events, Delegates, Properties and Methods. A class can only implement one abstract class only due non-existence of Multi-inheritance in C#. 1) After all that the interviewer came up with the question What if you had an Abstract class with only abstract methods, how would that be different from an interface? I didnt know the answer but I think its the inheritance as mentioned above right? 2) An another interviewer asked me what if you had a Public variable inside the interface, how would that be different than in Abstract Class? I insisted you can't have a public variable inside an interface. I didn't know what he wanted to hear but he wasn't satisfied either. ok dear also check this site this is also useful for you. http://www.codeproject.com/KB/architecture/OOP_Concepts_and_manymore.aspx

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote