Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // See https://aka.ms/new-console-template for more information
- //Console.WriteLine("Hello, World!");
- namespace project
- {
- public class Designation
- {
- private string emp_desg;
- public String EmpDes
- {
- get { return emp_desg; }
- set { emp_desg = value; }
- }
- private int lvl;
- public int Level
- {
- get { return lvl; }
- set { lvl = value; }
- }
- // constructor
- public Designation()
- {
- this.EmpDes = null;
- this.Level = 0;
- }
- public Designation(int level)
- {
- this.Level = level;
- }
- }
- public class level : Designation
- {
- string[] level1 = { "Manager", "HR" };
- string[] level2 = { "Developer", "Analyst" };
- string[] level3 = { "Maintanance", "Senior Manager" };
- public void Designation_Set_By_Lvl(employee e)
- {
- // two cases :
- // if the person is a new comer
- // if the person already has a designation so it won't assign anything.
- if(e.EmpDesignation.EmpDes == null)
- {
- if(e.EmpDesignation.Level == 1)
- {
- e.EmpDesignation.EmpDes = level1[0];
- Console.WriteLine("Running");
- }
- if (e.EmpDesignation.Level == 2)
- {
- e.EmpDesignation.EmpDes = level2[0];
- Console.WriteLine("Running");
- }
- if (e.EmpDesignation.Level == 3)
- {
- e.EmpDesignation.EmpDes = level3[0];
- Console.WriteLine("Running");
- }
- }
- else if (e.EmpDesignation.EmpDes != null)
- {
- if(e.EmpDesignation.Level == 1)
- {
- for(int i = 0; i < level1.Length; i++)
- {
- if (level1[i] == e.EmpDesignation.EmpDes)
- {
- if (i < (level1.Length - 1))
- {
- e.EmpDesignation.EmpDes = level1[i + 1];
- }
- else
- {
- e.EmpDesignation.EmpDes = level1[1];
- Console.WriteLine("Employee is at " + e.EmpDesignation.EmpDes);
- // at the end of the array
- Console.WriteLine("Employee is at the peak of his/her level 1 ");
- }
- }
- }
- }
- if (e.EmpDesignation.Level == 2)
- {
- for (int i = 0; i < level2.Length; i++)
- {
- if (level2[i] == e.EmpDesignation.EmpDes)
- {
- if (i < (level2.Length - 1))
- {
- e.EmpDesignation.EmpDes = level2[i + 1];
- }
- else
- {
- // at the end of the array
- Console.WriteLine("Employee is at the peak of his/her level 2 ");
- }
- }
- }
- }
- if (e.EmpDesignation.Level == 3)
- {
- for (int i = 0; i < level2.Length; i++)
- {
- if (level3[i] == e.EmpDesignation.EmpDes)
- {
- if (i < (level3.Length - 1))
- {
- e.EmpDesignation.EmpDes = level3[i + 1];
- }
- else
- {
- // at the end of the array
- Console.WriteLine("Employee is at the peak of his/her level 3 ");
- }
- }
- }
- }
- }
- }
- }
- public class Attendance :level
- {
- // Attendance
- private const int numberOfWorkingDays = 30;
- public int NumberOfWorkingDays
- {
- get { return numberOfWorkingDays; }
- // no setter will be there for const varibles because once assigned it cannot be change inside the program
- }
- private int numberOfPaidLeaves;
- public int NumberOfPaidLeaves
- {
- get { return numberOfPaidLeaves; }
- set { numberOfPaidLeaves = value; }
- }
- private int numberofExtraLeaves;
- public int NumberOfExtraLeaves
- {
- get { return numberofExtraLeaves; }
- set { numberofExtraLeaves = value; }
- }
- // Holidays and Deduction.
- private int totalSalaryDudcted; // no of extra leaves * one day salary
- public int TotalSalaryDudcted
- {
- get { return totalSalaryDudcted; }
- set { totalSalaryDudcted = value; }
- }
- private int oneDaySalary;
- public int OneDaySalary
- {
- get { return oneDaySalary; }
- set { oneDaySalary = value; }
- }
- private int salaryAfterDeduction;
- public int SalaryAfterDeduction
- {
- get { return salaryAfterDeduction; }
- set { salaryAfterDeduction = value; }
- }
- public Attendance()
- {
- }
- public Attendance(int numberofPaidLeaves, int numberofExtraLeaves)
- {
- this.NumberOfPaidLeaves = numberofPaidLeaves;
- this.NumberOfExtraLeaves = numberofExtraLeaves;
- }
- #region ---- FUNCTIONS ------
- public void ExecuteDeduction(employee e)
- {
- // leaves * one day salary
- // find one day salary.
- e.EmpAttendance.OneDaySalary = e.EmpSal.B_sal / e.EmpAttendance.NumberOfWorkingDays;
- if(e.EmpAttendance.NumberOfExtraLeaves > 0)
- {
- // find the total deduction
- e.EmpAttendance.TotalSalaryDudcted = e.EmpAttendance.NumberOfExtraLeaves * e.EmpAttendance.OneDaySalary;
- e.EmpAttendance.SalaryAfterDeduction = e.EmpSal.B_sal - e.EmpAttendance.TotalSalaryDudcted;
- }
- }
- public void ShowDeductionDetails(employee e)
- {
- Console.WriteLine("Total Working Days : " + e.EmpAttendance.NumberOfWorkingDays);
- Console.WriteLine("Total Paid Leaves : " + e.EmpAttendance.NumberOfPaidLeaves);
- Console.WriteLine("Total Extra Leaves : " + e.EmpAttendance.numberofExtraLeaves);
- Console.WriteLine("OneDaySalary : " + e.EmpAttendance.OneDaySalary);
- Console.WriteLine("Total Salary Deduction : " + e.EmpAttendance.TotalSalaryDudcted);
- Console.WriteLine("Total Salary After Deduction : " + e.EmpAttendance.SalaryAfterDeduction);
- }
- #endregion
- }
- public class salary : Attendance
- {
- private int b_sal;
- public int B_sal
- {
- get { return b_sal; }
- set { b_sal = value; }
- }
- private int ctc;
- public int Ctc
- {
- get { return ctc; }
- set { ctc = value; }
- }
- public salary()
- {
- this.B_sal = 0;
- this.Ctc = 0;
- }
- public void DisplpayEmployeeSalary(employee a)
- {
- Console.WriteLine("Employee Base Salary : " + a.EmpSal.B_sal);
- Console.WriteLine("Employee CTC : " + a.EmpSal.Ctc);
- }
- public void SetSalaryByLevel(employee a)
- {
- if (a.EmpDesignation.Level == 1)
- {
- a.EmpSal.Ctc = 1200000;
- a.EmpSal.B_sal = (a.EmpSal.Ctc / 12);
- }
- if (a.EmpDesignation.Level == 2)
- {
- a.EmpSal.Ctc = 2500000;
- a.EmpSal.B_sal = (a.EmpSal.Ctc / 12);
- }
- if (a.EmpDesignation.Level == 3)
- {
- a.EmpSal.Ctc = 4200000;
- a.EmpSal.B_sal = (a.EmpSal.Ctc / 12);
- }
- }
- }
- public class Allowances :salary
- {
- // make these private get and set all of them variables
- private int houseallowancces;
- public int Houseallowancces
- {
- get { return houseallowancces; }
- set { houseallowancces = value; }
- }
- private int carloanallowance;
- public int Carloanallowance
- {
- get { return carloanallowance; }
- set { carloanallowance = value; }
- }
- // add more allowances
- // if you want
- public Allowances()
- {
- // 0 is set because all these values will be Calculated based on the level of the person
- this.Houseallowancces = 0;
- this.Carloanallowance = 0;
- }
- public void Display_Employee_Allowances(employee a)
- {
- Console.WriteLine("Employee Car Loan Allowance : " + a.EmpAllw.Carloanallowance);
- Console.WriteLine("Employee House Loan Allowance : " + a.EmpAllw.Houseallowancces);
- }
- public void AllowanceSetByLevel(employee a)
- {
- if (a.EmpDesignation.Level == 1)
- {
- a.EmpAllw.Carloanallowance = 12000;
- a.EmpAllw.Houseallowancces = 18000;
- }
- if (a.EmpDesignation.Level == 2)
- {
- //sConsole.WriteLine("Running For Level 2");
- a.EmpAllw.Carloanallowance = 15000;
- a.EmpAllw.Houseallowancces = 20000;
- }
- if (a.EmpDesignation.Level == 3)
- {
- a.EmpAllw.Carloanallowance = 18000;
- a.EmpAllw.Houseallowancces = 22000;
- }
- }
- }
- public class employee : Allowances
- {
- private int employeeid;
- public int Employeeid
- {
- get { return employeeid; }
- set { employeeid = value; }
- }
- private string employeename;
- public string Employeename
- {
- get { return employeename; }
- set { employeename = value; }
- }
- private string employedate;
- public string Employedate
- {
- get { return employedate; }
- set { employedate = value; }
- }
- private salary emp_sal;
- public salary EmpSal
- {
- get { return emp_sal; }
- set
- {
- emp_sal = value;
- }
- }
- private Allowances emp_allw;
- public Allowances EmpAllw
- {
- get { return emp_allw; }
- set
- {
- emp_allw = value;
- }
- }
- private Designation emp_designation;
- public Designation EmpDesignation
- {
- get { return emp_designation; }
- set { emp_designation = value; }
- }
- private Attendance emp_attendance;
- public Attendance EmpAttendance
- {
- get { return emp_attendance; }
- set
- {
- emp_attendance = value;
- }
- }
- public employee()
- {
- }
- public employee(int emp_id, string emp_name, string emp_date,salary emp_sal, Allowances emp_all, Designation emp_des, Attendance emp_att)
- {
- this.Employeeid = emp_id;
- this.Employeename = emp_name;
- this.Employedate = emp_date;
- this.EmpSal = emp_sal;
- this.EmpAllw = emp_all;
- this.EmpDesignation = emp_des;
- this.EmpAttendance = emp_att;
- }
- public void displayemployeedetails()
- {
- Console.WriteLine("employee name:" + this.Employeename);
- Console.WriteLine("employee id:" + this.Employeeid);
- Console.WriteLine("employee dateofbirth:" + this.Employedate);
- Console.WriteLine("employee basesalary:" + this.EmpSal.B_sal);
- Console.WriteLine("employee CTC:" + this.EmpSal.Ctc);
- Console.WriteLine("employee houseallowances:" + this.EmpAllw.Houseallowancces);
- Console.WriteLine("employee carallowances:" + this.EmpAllw.Carloanallowance);
- }
- public void DisplayPaySlip(employee e)
- {
- // Call Few Functions to the prior.
- // DO NOT TOUCH THE FUNCTIONS AT ALL
- e.Designation_Set_By_Lvl(e);
- e.SetSalaryByLevel(e);
- e.AllowanceSetByLevel(e);
- e.ExecuteDeduction(e);
- Console.WriteLine("-----------------------------------------------------");
- //// Implement payslip from here
- e.Display_Employee_Allowances(e);
- e.DisplpayEmployeeSalary(e);
- e.ShowDeductionDetails(e);
- }
- public void TakeInput(employee e)
- {
- // TAKE INPUT AND HANDLE EXCEPTION HANDLING HERE ONLY
- // TAKE SEPERATE VARIABLES AND THEN TRY TO PASS THE VARIABLES IN THE CONTRUCTORS OF THE CLASSES. LIKE
- // DONE IN THE MAIN FUNCTION
- }
- }
- public class Program
- {
- public static void Main()
- {
- //// TO DO : DYNAMIC INPUT TAKING FROM USER
- Attendance atn = new Attendance(5,5);
- Designation ds = new Designation(2);
- salary s = new salary();
- Allowances al = new Allowances();
- employee e = new employee(1415, "Sucharita", "24/05/1999", s, al, ds, atn);
- e.DisplayPaySlip(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement