public double GetPay() { if (_employee.GetType().IsAssignableFrom(typeof(ContractEmployee))) { return(((ContractEmployee)_employee).HourlyRate); } throw new Exception("Not a Contract Employee"); }
public double GetPay() { if (!_employee.GetType().IsAssignableFrom(typeof(VisitingEmployee))) { throw new Exception("Not a Visiting Employee"); } return(((VisitingEmployee)_employee).RatePerVisit); }
public double GetPay() { if (_employee.GetType().IsAssignableFrom(typeof(PermanentEmployee))) { return(((PermanentEmployee)_employee).MonthlySalary); } throw new Exception("Not a Permanent Employee"); }
} // Employee Age /// <summary> /// Prints details of the employee file /// </summary> /// <param name="employee">The employee to which the file will be printed</param> public void PrintFile(IBaseEmployee employee) { Console.WriteLine($"{employee.GetType().Name} File : \nID:{employee.ID}\nName:{employee.Name}\nAge:{employee.Age}"); }
/// <summary> /// Calculates the salary of an employee based on the type /// passed /// </summary> /// <param name="employee">The employee to calculate the salary for</param> public void CalcSalary(IBaseEmployee employee) { @switch[employee.GetType()].Invoke(); Console.WriteLine($"The salary is : {this.salary}"); }