C Create a Worker classes that are derived from Employee cla

C#

Create a “Worker” classes that are derived from Employee class. In Worker class, it has one field, yearWorked. It includes constructor(s) and properties. It also includes two functions: first, calcYearWorked function, it takes one parameter (currentyear) and calculates the number of year the worker has been working (current year–yearStartedWked) and save it in the yearWorked variable. Second, the calcCurSalary function that calculate the current year salary by overriding the base class function using initial salary with 3% yearly increment.

(Employee class has been previously created)

Employee.cs

public class Employee
{
private string firstName;
private string lastName;
private int workID;
private int yearStartedWked;
private double initSalary;
private readonly double curSalary;
public Employee(string f, string l, int w, int y, double i, double c){
firstName = f;
lastName = l;
workID = w;
yearStartedWked = y;
initSalary = i;
curSalary = c;
}
public void calcCurSalary(){
initSalary = curSalary;
}
  
}

Solution

public class Worker:Employee

{

Worker()

{

public int yearWorked;

}

public void calcYearWorked(int currentyear)

{

yearWorked=currentyear-yearStartedWked;

}

public void calCurSalary()

{

curSalary=initSalary*0.03;

}


C# Create a “Worker” classes that are derived from Employee class. In Worker class, it has one field, yearWorked. It includes constructor(s) and properties. It
C# Create a “Worker” classes that are derived from Employee class. In Worker class, it has one field, yearWorked. It includes constructor(s) and properties. It

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site