Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // See https://aka.ms/new-console-template for more information
- namespace DXC_Employee
- {
- abstract class SalarayCounter
- {
- public const int NoofWorkingDays = 30;
- public static int incrementby20(Employee emp)
- {
- //Console.WriteLine((emp.emp_Salary.BaseSalary * 20) / 100);
- return (emp.emp_Salary.BaseSalary * 20) / 100;
- }
- public static int incrementby30(Employee emp)
- {
- return (emp.emp_Salary.BaseSalary * 30) / 100;
- }
- public static int incrementby40(Employee emp)
- {
- return (emp.emp_Salary.BaseSalary * 40) / 100;
- }
- public static int getOneDaySalary(Employee passedEmp)
- {
- return (passedEmp.emp_Salary.BaseSalary / NoofWorkingDays);
- }
- //Gives the total money that has to be deducted from the employees salary.
- public static int totalMoneyDedctionValue(Employee passedEmp)
- {
- int oneDaySalary = SalarayCounter.getOneDaySalary(passedEmp);
- return oneDaySalary * passedEmp.emp_Attendance.TotalExtraLeaves;
- }
- public static int incrementByPercentage(int value, int percentage)
- {
- return (value * percentage) / 100;
- }
- }
- // Custom class for designation and level check
- abstract class DesignationSelector
- {
- /// <summary>
- /// Made specifically for the array
- /// </summary>
- public static Designations[] designations = new Designations[] {
- new Designations("Manager",1),
- new Designations("Deputy_Manager",1),
- new Designations("Chief_Manager",1),
- new Designations("AGM",2),
- new Designations("DGM",2),
- new Designations("GM",2),
- new Designations("CGM",3),
- new Designations("DMD",3),
- new Designations("MD",3)
- };
- public static string getDesignation(int passedIndex)
- {
- return DesignationSelector.designations[passedIndex].Designation;
- }
- public static int getDesignationLevel(int index)
- {
- return DesignationSelector.designations[index].DesignationLevel;
- }
- public static int getDesignationsLength()
- {
- return DesignationSelector.designations.Length;
- }
- public static void getDesignation(Employee emp)
- {
- Console.WriteLine("Designation : " + emp.empDes.Designation);
- Console.WriteLine("Designation Level : " + emp.empDes.DesignationLevel);
- }
- }
- public class Designations
- {
- private string designation;
- private int designationLevel;
- public string Designation
- {
- get { return designation; }
- set { designation = value; }
- }
- public int DesignationLevel
- {
- get { return designationLevel; }
- set { designationLevel = value; }
- }
- // safety
- public Designations()
- {
- this.Designation = " WAITING FOR THE INPUT ";
- this.DesignationLevel = -1;
- }
- public Designations(string passedDesignation, int passedlevel)
- {
- this.designation = passedDesignation;
- this.designationLevel = passedlevel;
- //Console.WriteLine("Value loaded for Designation : ");
- }
- }
- public class Attendance
- {
- private int totalDaysOfWork;
- private int totalHoursOfWork;
- private int totalPaidHolidays;
- private int totalExtraLeaves;
- private int totalSalaryAfterDeduction;
- private int amountDeductedFromSalary;
- //public Boolean runValue = false;
- public int TotalDaysOfWork
- {
- get { return totalDaysOfWork; }
- set { totalDaysOfWork = value; }
- }
- public int TotalHoursOfWork
- {
- get { return totalHoursOfWork; }
- set { totalHoursOfWork = value; }
- }
- public int TotalPaidHolidays
- {
- get { return totalPaidHolidays; }
- set { totalPaidHolidays = value; }
- }
- public int TotalExtraLeaves
- {
- get { return totalExtraLeaves; }
- set { totalExtraLeaves = value; }
- }
- public int TotalSalaryAfterDeduction
- {
- get { return totalSalaryAfterDeduction; }
- set { totalSalaryAfterDeduction = value; }
- }
- public int AmountDeductedFromSalary
- {
- get { return amountDeductedFromSalary; }
- set { amountDeductedFromSalary = value; }
- }
- public Attendance()
- {
- }
- public Attendance(int passed_TotalDaysOfWork, int passed_TotalHoursOfWork, int passed_TotalPaidHolidays, int passed_TotalExtraLeaves)
- {
- this.TotalDaysOfWork = passed_TotalDaysOfWork;
- this.TotalHoursOfWork = passed_TotalHoursOfWork;
- this.TotalPaidHolidays = passed_TotalPaidHolidays;
- this.TotalExtraLeaves = passed_TotalExtraLeaves;
- this.TotalSalaryAfterDeduction = 0;
- //Console.WriteLine("Value loaded for Attendance : ");
- }
- public void Display_Total_Attendance(Employee emp)
- {
- Console.WriteLine( "Total Work Days : " + emp.emp_Attendance.TotalDaysOfWork);
- Console.WriteLine("Total Hours of Work : " + emp.emp_Attendance.TotalHoursOfWork);
- Console.WriteLine("Total Paid Holidays : " + emp.emp_Attendance.TotalPaidHolidays);
- Console.WriteLine("Total Extra Leaves : " + emp.emp_Attendance.TotalExtraLeaves);
- }
- public void Deduct_Salary(Employee emp)
- {
- ///////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////
- ///
- if (emp.emp_Attendance.TotalExtraLeaves > 0 /*&& !runValue*/)
- {
- // problem was here
- //TotalSalaryAfterDeduction = emp.emp_Salary.BaseSalary -= SalarayCounter.totalMoneyDedctionValue(emp);
- TotalSalaryAfterDeduction = emp.emp_Salary.BaseSalary - SalarayCounter.totalMoneyDedctionValue(emp);
- Console.WriteLine("Total Salary Deduction Breakup : " +
- "\n One day salary : " + SalarayCounter.getOneDaySalary(emp) +
- "\n Extra Leaves : " + emp.emp_Attendance.TotalExtraLeaves +
- "\n Total Salary Deducted : " + SalarayCounter.totalMoneyDedctionValue(emp));
- AmountDeductedFromSalary = SalarayCounter.totalMoneyDedctionValue(emp);
- //runValue = true;
- return;
- }
- Console.WriteLine("No Deduction ");
- }
- }
- public class Salary:Attendance
- {
- private int baseSalary;
- public int BaseSalary
- {
- get { return baseSalary; }
- set { baseSalary = value; }
- }
- private int costToCompany;
- public int CostToCompany
- {
- get { return costToCompany; }
- set { costToCompany = value; }
- }
- public Salary()
- {
- }
- public Salary(int passed_Base_Salary, int passed_Cost_To_Company)
- {
- this.BaseSalary = passed_Base_Salary;
- this.CostToCompany = passed_Cost_To_Company;
- //Console.WriteLine("Value loaded for Salary : ");
- }
- public void Display_Employee_Salary(Employee emp)
- {
- Console.WriteLine("--------------------------------------------------");
- Console.WriteLine("Base Salary : " + emp.emp_Salary.BaseSalary);
- Console.WriteLine("Cost to Company : " + emp.emp_Salary.CostToCompany);
- Console.WriteLine("--------------------------------------------------");
- }
- //public void Increment_Base_Salary_By_Designation(Designation passedEmpObj, Employee passedemp_Base_Salary)
- //{
- // if (passedEmpObj == Designation.MANAGER || passedEmpObj == Designation.DEPUTY_MANAGER || passedEmpObj == Designation.CHIEF_MANAGER)
- // {
- // // Increment By 20%
- // Console.WriteLine("Incrementing by 20%");
- // passedemp_Base_Salary.emp_Salary.BaseSalary = SalarayCounter.incrementby20(passedemp_Base_Salary.emp_Salary.BaseSalary);
- // }
- // if (passedEmpObj == Designation.ASSISTANT_GENERAL_MANAGER || passedEmpObj == Designation.DEPUTY_GENERAL_MANAGER || passedEmpObj == Designation.GENERAL_MANAGER)
- // {
- // // Increment By 30%
- // Console.WriteLine("Incrementing by 30%");
- // passedemp_Base_Salary.emp_Salary.BaseSalary = SalarayCounter.incrementby30(passedemp_Base_Salary.emp_Salary.BaseSalary);
- // }
- // if (passedEmpObj == Designation.CHIEF_GENERAL_MANAGER || passedEmpObj == Designation.DEPUTY_MANAGEMENT_DIRECTOR || passedEmpObj == Designation.MANAGEMENT_DIRECTOR)
- // {
- // // Increment By 40%
- // Console.WriteLine("Incrementing by 40%");
- // passedemp_Base_Salary.emp_Salary.BaseSalary = SalarayCounter.incrementby40(passedemp_Base_Salary.emp_Salary.BaseSalary);
- // }
- //}
- }
- public class Allowances : Salary
- {
- private int houseLoanAllowance;
- private int carLoanAllowance;
- private int basicRentAllowance;
- public int HouseLoanAllowance
- {
- get { return houseLoanAllowance; }
- set { houseLoanAllowance = value; }
- }
- public int CarLoanAllowance
- {
- get { return carLoanAllowance; }
- set { carLoanAllowance = value; }
- }
- public int BasicRentAllowance
- {
- get { return basicRentAllowance; }
- set
- {
- basicRentAllowance = value;
- }
- }
- public Allowances()
- {
- }
- public Allowances(int passed_House_Loan_Allowance, int passed_Car_Loan_Allowance, int Basic_Rent_Allowance)
- {
- this.HouseLoanAllowance = passed_House_Loan_Allowance;
- this.CarLoanAllowance = passed_Car_Loan_Allowance;
- this.BasicRentAllowance = Basic_Rent_Allowance;
- //Console.WriteLine("Value Loaded for Allowances : ");
- }
- public void Display_Employee_Allowances(Employee emp)
- {
- Console.WriteLine(" /////////////////////////// ");
- Console.WriteLine("The House Loan Allowance is : " + emp.emp_Allowances.HouseLoanAllowance);
- Console.WriteLine("The Car Loan Allowance is : " + emp.emp_Allowances.CarLoanAllowance);
- Console.WriteLine("The Basic Rent Allowance is : " + emp.emp_Allowances.BasicRentAllowance);
- Console.WriteLine(" /////////////////////////// ");
- }
- public void Increment_Base_By_Designation(Employee emp)
- {
- int level = emp.empDes.DesignationLevel;
- if (level == 1)
- {
- emp.emp_Salary.BaseSalary += SalarayCounter.incrementby20(emp);
- }
- if (level == 2)
- {
- emp.emp_Salary.BaseSalary += SalarayCounter.incrementby30(emp);
- }
- if (level == 3)
- {
- emp.emp_Salary.BaseSalary += SalarayCounter.incrementby40(emp);
- }
- }
- public void Increment_Allow_By_Designation(Employee emp)
- {
- int level = emp.empDes.DesignationLevel;
- if(level == 1)
- {
- emp.emp_Allowances.CarLoanAllowance += SalarayCounter.incrementByPercentage(emp.emp_Allowances.CarLoanAllowance, 20);
- emp.emp_Allowances.BasicRentAllowance += SalarayCounter.incrementByPercentage(emp.emp_Allowances.BasicRentAllowance, 20);
- emp.emp_Allowances.HouseLoanAllowance += SalarayCounter.incrementByPercentage(emp.emp_Allowances.HouseLoanAllowance, 20);
- }
- if (level == 2)
- {
- emp.emp_Allowances.CarLoanAllowance += SalarayCounter.incrementByPercentage(emp.emp_Allowances.CarLoanAllowance, 30);
- emp.emp_Allowances.BasicRentAllowance += SalarayCounter.incrementByPercentage(emp.emp_Allowances.BasicRentAllowance, 30);
- emp.emp_Allowances.HouseLoanAllowance += SalarayCounter.incrementByPercentage(emp.emp_Allowances.HouseLoanAllowance, 30);
- }
- if (level == 3)
- {
- emp.emp_Allowances.CarLoanAllowance += SalarayCounter.incrementByPercentage(emp.emp_Allowances.CarLoanAllowance, 40);
- emp.emp_Allowances.BasicRentAllowance += SalarayCounter.incrementByPercentage(emp.emp_Allowances.BasicRentAllowance, 40);
- emp.emp_Allowances.HouseLoanAllowance += SalarayCounter.incrementByPercentage(emp.emp_Allowances.HouseLoanAllowance, 40);
- }
- }
- //public void Increment_Allowance_By_Designation(Designation passedEmpObj, Employee passedEmp)
- //{
- // if (passedEmpObj == Designation.MANAGER || passedEmpObj == Designation.DEPUTY_MANAGER || passedEmpObj == Designation.CHIEF_MANAGER)
- // {
- // passedEmp.emp_Allowances.HouseLoanAllowance = SalarayCounter.incrementby20(passedEmp.emp_Allowances.HouseLoanAllowance);
- // passedEmp.emp_Allowances.CarLoanAllowance = SalarayCounter.incrementby20(passedEmp.emp_Allowances.CarLoanAllowance);
- // passedEmp.emp_Allowances.BasicRentAllowance = SalarayCounter.incrementby20(passedEmp.emp_Allowances.HouseLoanAllowance);
- // }
- // if (passedEmpObj == Designation.ASSISTANT_GENERAL_MANAGER || passedEmpObj == Designation.DEPUTY_GENERAL_MANAGER || passedEmpObj == Designation.GENERAL_MANAGER)
- // {
- // passedEmp.emp_Allowances.HouseLoanAllowance = SalarayCounter.incrementby30(passedEmp.emp_Allowances.HouseLoanAllowance);
- // passedEmp.emp_Allowances.CarLoanAllowance = SalarayCounter.incrementby30(passedEmp.emp_Allowances.CarLoanAllowance);
- // passedEmp.emp_Allowances.BasicRentAllowance = SalarayCounter.incrementby30(passedEmp.emp_Allowances.HouseLoanAllowance);
- // }
- // if (passedEmpObj == Designation.CHIEF_GENERAL_MANAGER || passedEmpObj == Designation.DEPUTY_MANAGEMENT_DIRECTOR || passedEmpObj == Designation.MANAGEMENT_DIRECTOR)
- // {
- // passedEmp.emp_Allowances.HouseLoanAllowance = SalarayCounter.incrementby40(passedEmp.emp_Allowances.HouseLoanAllowance);
- // passedEmp.emp_Allowances.CarLoanAllowance = SalarayCounter.incrementby40(passedEmp.emp_Allowances.CarLoanAllowance);
- // passedEmp.emp_Allowances.BasicRentAllowance = SalarayCounter.incrementby40(passedEmp.emp_Allowances.HouseLoanAllowance);
- // }
- //}
- }
- public class Employee : Allowances
- {
- public Salary emp_Salary;
- public Allowances emp_Allowances;
- public Attendance emp_Attendance;
- // employees
- public string name;
- public int age;
- public int emp_id;
- public Designations empDes;
- //public int DOB;
- // constructor.
- public Employee()
- {
- }
- public Employee(Attendance emp_Attendance, Salary emp_Salary, Allowances emp_Allowances, string name, int age, int emp_id, Designations des)
- {
- this.emp_Attendance = emp_Attendance;
- this.emp_Salary = emp_Salary;
- this.emp_Allowances = emp_Allowances;
- this.name = name;
- this.age = age;
- this.emp_id = emp_id;
- this.empDes = des;
- //Console.WriteLine("Value loaded for Employee : ");
- }
- /// <summary>
- /// Displays Employee Details.
- /// </summary>
- /// <param name="emp"></param>
- public void Display_Employee_Details()
- {
- Console.WriteLine("The Name of the employee is : " + this.name);
- Console.WriteLine("The Age of the employee is : " + this.age);
- Console.WriteLine("The Emp_id of the employee is : " + this.emp_id);
- Display_Employee_Salary(this);
- Display_Employee_Allowances(this);
- Console.WriteLine("The Designation of the employee is : " + this.empDes);
- }
- public void Display_Employee_Designation()
- {
- Console.WriteLine("The Designation of the employee is : " +
- "\nEmployee Designation : "+ this.empDes.Designation +
- "\nEmployee Level : " + this.empDes.DesignationLevel);
- }
- public void IncrementDesignation()
- {
- //looping through the designations
- string des = this.empDes.Designation;
- int lvl = this.empDes.DesignationLevel;
- //Console.WriteLine(des + lvl);
- for (int i = 0; i < DesignationSelector.getDesignationsLength() - 1; i++)
- {
- if (des == DesignationSelector.getDesignation(i))
- {
- des = DesignationSelector.getDesignation(i + 1);
- lvl = DesignationSelector.getDesignationLevel(i + 1);
- break;
- }
- }
- this.empDes.Designation = des;
- this.empDes.DesignationLevel = lvl;
- Console.WriteLine("Employee Designation has been incremented to : "
- + "\nEmployee Designation : " + empDes.Designation + "\n" +
- "Employee Level : " + empDes.DesignationLevel);
- }
- public void Promote_Employee()
- {
- // To be Implemented
- IncrementDesignation();
- Increment_Allow_By_Designation(this);
- Increment_Base_By_Designation(this);
- Display_Employee_Allowances(this);
- }
- }
- public class Manager : Employee
- {
- public Attendance atn;
- public Salary sal;
- public Allowances all;
- public Designations ds;
- public Employee emp;
- public Manager()
- {
- this.atn = new Attendance(SalarayCounter.NoofWorkingDays,(30*8),5,5);
- this.sal = new Salary(35000,400000);
- this.all = new Allowances(15000,18000,25000);
- this.ds = new Designations("Manager", 1);
- this.emp = new Employee(atn,sal,all,"Rahul Mishra",22,142218,ds);
- //Console.WriteLine("Value inserted for Manger Cosntructor");
- }
- public void ShowPaySlip()
- {
- Console.WriteLine();
- String[,] paySlip1 = new String[4, 4];
- paySlip1[0, 1] = " PAYSLIP";
- paySlip1[1, 0] = " Employee Designation : ";
- paySlip1[2, 0] = " Employee ID : ";
- paySlip1[3, 0] = " Employee Name : ";
- paySlip1[1, 1] = emp.empDes.Designation;
- paySlip1[2, 1] = Convert.ToString(emp.emp_id);
- paySlip1[3, 1] = Convert.ToString(emp.name);
- for (int i = 0; i <= 3; i++)
- {
- for (int j = 0; j <= 3; j++)
- {
- Console.Write(paySlip1[i, j]);
- }
- Console.WriteLine();
- }
- Console.WriteLine("-------------------------------------------------------------------------------------------------------------------------");
- String[,] paySlip = new String[6,6];
- paySlip[0, 0] = "EARNINGS ";
- paySlip[0, 1] = "AMOUNT ";
- paySlip[0, 2] = "DEUCTIONS ";
- paySlip[0, 3] = "AMOUNT ";
- paySlip[1, 0] = "Basic Salary ";
- paySlip[2, 0] = "House Loan Allowance ";
- paySlip[3, 0] = "Car Loan Allowance ";
- paySlip[4, 0] = "Basic Rent Allowance ";
- paySlip[5, 0] = "Total Earnings : ";
- int total1 = (emp.emp_Salary.BaseSalary + emp.emp_Allowances.HouseLoanAllowance + emp.emp_Allowances.CarLoanAllowance + emp.emp_Allowances.BasicRentAllowance);
- paySlip[1, 1] = Convert.ToString(emp.emp_Salary.BaseSalary);
- paySlip[2, 1] = Convert.ToString(emp.emp_Allowances.HouseLoanAllowance);
- paySlip[3, 1] = Convert.ToString(emp.emp_Allowances.CarLoanAllowance);
- paySlip[4, 1] = Convert.ToString(emp.emp_Allowances.BasicRentAllowance);
- paySlip[5, 1] = Convert.ToString((total1));
- // row change , col same
- paySlip[1,2] = " Salary Deduction ";
- paySlip[5, 2] = " Total Deduction : ";
- all.Deduct_Salary(emp);
- int total2 = all.AmountDeductedFromSalary;
- paySlip[1, 3] = Convert.ToString(all.AmountDeductedFromSalary);
- paySlip[5, 3] = Convert.ToString(total2);
- for (int i = 0; i < 6; i++)
- {
- for(int j = 0; j < 6; j++)
- {
- Console.Write(paySlip[i, j]);
- }
- Console.WriteLine();
- }
- Console.WriteLine();
- Console.WriteLine("-------------------------------------------------------------------------------------------------------------------------");
- Console.WriteLine(" Net Payable Amount : " + (total1 - total2));
- Console.WriteLine("-------------------------------------------------------------------------------------------------------------------------");
- return;
- }
- }
- class program
- {
- public static void Main()
- {
- Manager mp = new Manager();
- //mp.ShowPaySlip();
- //.Increment_Allow_By_Designation(mp.emp);
- //mp.Increment_Base_By_Designation(mp.emp);
- mp.ShowPaySlip();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement