C# Create a base Employee class with instance variables and properties Solution

Create a base Employee class with instance variables and properties: FirstName & LastName. The constructor for Employee should accept values for firstname, lastname and socialSecurityNumber and initial the values. Employee should have a toString method to output the values for each employee.

Create a derived class for an employee type Pieceworker. A pieceworker is paid a fee for each piece completed, i.e., # pieces * fee per piece. Class Pieceworker should add private instance variables fee and pieces. Pieceworker should inherit from Employee; adding in an earnings method to calculate earnings. Create a constructor to initialize firstname, lastname, socialSecurityNumber, fee and pieces. Override the toString method to output all variables.

Create a third class to create objects of Pieceworker, then calculate earnings; output all values including earnings.


Powered by