public double GetPay()
 {
     if (_employee.GetType().IsAssignableFrom(typeof(ContractEmployee)))
     {
         return(((ContractEmployee)_employee).HourlyRate);
     }
     throw new Exception("Not a Contract Employee");
 }
Esempio n. 2
0
 public double GetPay()
 {
     if (!_employee.GetType().IsAssignableFrom(typeof(VisitingEmployee)))
     {
         throw new Exception("Not a Visiting Employee");
     }
     return(((VisitingEmployee)_employee).RatePerVisit);
 }
Esempio n. 3
0
 public double GetPay()
 {
     if (_employee.GetType().IsAssignableFrom(typeof(PermanentEmployee)))
     {
         return(((PermanentEmployee)_employee).MonthlySalary);
     }
     throw new Exception("Not a Permanent Employee");
 }
Esempio n. 4
0
        }                           // 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}");
        }
Esempio n. 5
0
 /// <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}");
 }