Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.95 KB | None | 0 0
  1.  
  2. public abstract class Employee
  3. {
  4.     public int Id { get; set; }
  5.     public string Name { get; set; }
  6.     public string ReportType { get; set; }
  7.     public int Salary { get; set; }
  8.  
  9.     public virtual string GetProjectDetails(int employeeId)
  10.     {
  11.         return "Base Project";
  12.     }
  13.  
  14.     public virtual string GetEmployeeDetails(int employeeId)
  15.     {
  16.         return $"Employee: { Name }";
  17.     }
  18.  
  19.     public abstract bool InsertIntoEmployeeTable(Employee em);
  20.  
  21.     public void GenerateReport(Employee em)
  22.     {
  23.         if (ReportType == "CSV")
  24.         {
  25.             // Report generation code with employee data saved as CSV file.
  26.         }
  27.  
  28.         if (ReportType == "PDF")
  29.         {
  30.             // Report generation code with employee data saved as CSV file.
  31.         }
  32.     }
  33. }
  34.  
  35. public class RegularEmployee : Employee
  36. {
  37.     public override string GetProjectDetails(int employeeId)
  38.     {
  39.         return "Child Project";
  40.     }
  41.  
  42.     public override string GetEmployeeDetails(int employeeId)
  43.     {
  44.         return "Child Employee";
  45.     }
  46.  
  47.     public override bool InsertIntoEmployeeTable(Employee em)
  48.     {
  49.         // insert code;
  50.         return true;
  51.     }
  52. }
  53.  
  54. public class SubcontractorEmployee : Employee
  55. {
  56.     public float ParentCompanyFee { get; set; }
  57.  
  58.     public override string GetProjectDetails(int employeeId)
  59.     {
  60.         return "Child Project";
  61.     }
  62.  
  63.     public override string GetEmployeeDetails(int employeeId)
  64.     {
  65.         throw new NotImplementedException();
  66.     }
  67.  
  68.     public override bool InsertIntoEmployeeTable(Employee em)
  69.     {
  70.         // subcontractors are not stored in the Employee table
  71.         return false;
  72.     }
  73.  
  74.     public float GetCompanyFee(float netSalary)
  75.     {
  76.         var feeCalculator = new CheatingFeeCalculator();
  77.  
  78.         float baseFee = feeCalculator.CalculateBaseFee(netSalary, ParentCompanyFee);
  79.         float finalFee = baseFee * 0.95;
  80.  
  81.         return finalFee;
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement