Anda di halaman 1dari 5

using using using using

System; System.Collections.Generic; System.Linq; System.Text;

namespace SalaryCalculatorProj { class Program { static void Main(string[] args) { Developer D1 = new Developer("10322", "MAHESH", 10000, 1000, "TECHIES ", "SENSOR NODE APPLICATION"); Developer D2 = new Developer("10333", "SUMAN", 10000, 1000, "TECH LA CARTE", "CLOUD COMPUTING"); HRExecutive H = new HRExecutive("E010", "XYZ", 12000, 3000, 2); ProjectManager P = new ProjectManager("P1010", "ABC", 16000, 20000, 2 0, "TECHIES", "SENSOR NODE APPLICATION"); Console.WriteLine("Salary of developer 1:" + Salary_Calculator.Comput eSalary(D1)); Console.WriteLine("Salary of developer 2:" + Salary_Calculator.Comput eSalary(D2)); Console.WriteLine("Salary of HR EXECUTIVE:" + Salary_Calculator.Compu teSalary(H)); Console.WriteLine("Salary of Project Manager:" + Salary_Calculator.Co mputeSalary(P));

} } }

using using using using

System; System.Collections.Generic; System.Linq; System.Text;

namespace SalaryCalculatorProj { public class Employee

{ string empId; string empName; double basicSalary; double allowance; public Employee(string _empId, string _empname, double _basicSalary, dou ble _allowance) { empId = _empId; empName = _empname; basicSalary = _basicSalary; allowance = _allowance; } public double GetBasicSalary() { return basicSalary; } public double GetAllowance() { return allowance; } } }

using using using using

System; System.Collections.Generic; System.Linq; System.Text;

namespace SalaryCalculatorProj { class Developer:Employee { string teamName; string projectName; Developer(string __empId, string _empname, double _basicSalary, double _ alllowance, string teamName, string projectName) : base(__empId, _empname, _basicSalary, _alllowance) { this.teamName = teamName; this.projectName = projectName; }

public string GetteamName() { return teamName; }

public string GetprojectName() { return projectName; }

} }

using using using using

System; System.Collections.Generic; System.Linq; System.Text;

namespace SalaryCalculatorProj { class ProjectManager:Employee { int teamSize; string projectName; string TeamName; double SplAllowance; ProjectManager(string __empId, string _empname, double _basicSalary, dou ble _alllowance, int _teamSize, string _TeamName, string _projectName) : base(__empId, _empname, _basicSalary, _alllowance) { teamSize = _teamSize; projectName = _projectName; TeamName = _TeamName; if (teamSize != 0) if (teamSize > 20) SplAllowance = 0.3; else if (teamSize > 10) SplAllowance = 0.2; else SplAllowance = 0.1; } public double GetSplAllowance() { return SplAllowance; }

using using using using

System; System.Collections.Generic; System.Linq; System.Text;

namespace SalaryCalculatorProj { class HRExecutive:Employee { int numOfCandidatesRecruited; double performanceBonus; HRExecutive(string __empId, string _empname, double _basicSalary, double _alllowance, int _numOfCandidatesRecruited) : base(__empId, _empname, _basicSalary, _alllowance) { numOfCandidatesRecruited = _numOfCandidatesRecruited; if(numOfCandidatesRecruited!=0) if (numOfCandidatesRecruited >= 50) performanceBonus = 0.3; else if (numOfCandidatesRecruited >= 20) performanceBonus = 0.2; else performanceBonus = 0.1; } public double GetPerformanceBonus() { return performanceBonus; } } }

using using using using

System; System.Collections.Generic; System.Linq; System.Text;

namespace SalaryCalculatorProj { class Salary_Calculator { public static double ComputeSalary(Employee e)/*We have added e due to inheritance because it expects employee object and developer or HR Executive or Project Manager is an employee*/ { double monthlySalary = 0.0; monthlySalary = e.GetBasicSalary() + e.GetAllowance(); if (e.GetType().Name == "ProjectManager") { ProjectManager p = (ProjectManager)e; monthlySalary = p.GetSplAllowance() * monthlySalary + monthlySal ary; } else if (e.GetType().Name == "HRExecutive") { HRExecutive h = (HRExecutive)e; monthlySalary = h.GetPerformanceBonus() * monthlySalary + monthl ySalary; } return monthlySalary; } } }

Anda mungkin juga menyukai