Advertisement
_vish_99__

WEEKLY_PROJECT_SUCHARITHA

Jul 15th, 2022
1,108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.15 KB | None | 0 0
  1. // See https://aka.ms/new-console-template for more information
  2. //Console.WriteLine("Hello, World!");
  3.  
  4.  
  5. namespace project
  6. {
  7.     public class Designation
  8.     {
  9.         private string emp_desg;
  10.         public String EmpDes
  11.         {
  12.             get { return emp_desg; }
  13.             set { emp_desg = value; }
  14.         }
  15.         private int lvl;
  16.         public int Level
  17.         {
  18.             get { return lvl; }
  19.             set { lvl = value; }
  20.         }
  21.  
  22.  
  23.         // constructor
  24.         public Designation()
  25.         {
  26.             this.EmpDes = null;
  27.             this.Level = 0;
  28.         }
  29.  
  30.         public Designation(int level)
  31.         {
  32.             this.Level = level;
  33.         }
  34.  
  35.  
  36.     }
  37.     public class level : Designation
  38.     {
  39.  
  40.  
  41.         string[] level1 = { "Manager", "HR" };
  42.         string[] level2 = { "Developer", "Analyst" };
  43.         string[] level3 = { "Maintanance", "Senior Manager" };
  44.  
  45.  
  46.         public void Designation_Set_By_Lvl(employee e)
  47.         {
  48.             // two cases :
  49.             // if the person is a new comer
  50.             // if the person already has a designation so it won't assign anything.
  51.  
  52.             if(e.EmpDesignation.EmpDes == null)
  53.             {
  54.                 if(e.EmpDesignation.Level == 1)
  55.                 {
  56.                     e.EmpDesignation.EmpDes = level1[0];
  57.                     Console.WriteLine("Running");
  58.                 }
  59.                 if (e.EmpDesignation.Level == 2)
  60.                 {
  61.                     e.EmpDesignation.EmpDes = level2[0];
  62.                     Console.WriteLine("Running");
  63.  
  64.                 }
  65.                 if (e.EmpDesignation.Level == 3)
  66.                 {
  67.                     e.EmpDesignation.EmpDes = level3[0];
  68.                     Console.WriteLine("Running");
  69.  
  70.                 }
  71.             }
  72.  
  73.             else if (e.EmpDesignation.EmpDes != null)
  74.             {
  75.                 if(e.EmpDesignation.Level == 1)
  76.                 {
  77.                     for(int i = 0; i < level1.Length; i++)
  78.                     {
  79.                         if (level1[i] == e.EmpDesignation.EmpDes)
  80.                         {
  81.                             if (i < (level1.Length - 1))
  82.                             {
  83.                                 e.EmpDesignation.EmpDes = level1[i + 1];
  84.                             }
  85.                             else
  86.                             {
  87.                                 e.EmpDesignation.EmpDes = level1[1];
  88.                                 Console.WriteLine("Employee is at " + e.EmpDesignation.EmpDes);
  89.  
  90.                                 // at the end of the array
  91.                                 Console.WriteLine("Employee is at the peak of his/her level 1 ");
  92.                             }
  93.                         }
  94.                     }
  95.                 }
  96.  
  97.  
  98.  
  99.                 if (e.EmpDesignation.Level == 2)
  100.                 {
  101.                     for (int i = 0; i < level2.Length; i++)
  102.                     {
  103.                         if (level2[i] == e.EmpDesignation.EmpDes)
  104.                         {
  105.                             if (i < (level2.Length - 1))
  106.                             {
  107.                                 e.EmpDesignation.EmpDes = level2[i + 1];
  108.                             }
  109.                             else
  110.                             {
  111.                                 // at the end of the array
  112.                                 Console.WriteLine("Employee is at the peak of his/her level 2 ");
  113.                             }
  114.                         }
  115.                     }
  116.                 }
  117.  
  118.  
  119.                 if (e.EmpDesignation.Level == 3)
  120.                 {
  121.                     for (int i = 0; i < level2.Length; i++)
  122.                     {
  123.                         if (level3[i] == e.EmpDesignation.EmpDes)
  124.                         {
  125.                             if (i < (level3.Length - 1))
  126.                             {
  127.                                 e.EmpDesignation.EmpDes = level3[i + 1];
  128.                             }
  129.                             else
  130.                             {
  131.                                 // at the end of the array
  132.                                 Console.WriteLine("Employee is at the peak of his/her level 3 ");
  133.                             }
  134.                         }
  135.                     }
  136.                 }
  137.  
  138.  
  139.             }
  140.         }
  141.     }
  142.  
  143.  
  144.     public class Attendance :level
  145.     {
  146.         // Attendance
  147.         private const int numberOfWorkingDays = 30;
  148.         public int NumberOfWorkingDays
  149.         {
  150.             get { return numberOfWorkingDays; }
  151.             // no setter will be there for const varibles because once assigned it cannot be change inside the program
  152.         }
  153.         private int numberOfPaidLeaves;
  154.         public int NumberOfPaidLeaves
  155.         {
  156.             get { return numberOfPaidLeaves; }
  157.             set { numberOfPaidLeaves = value; }
  158.         }
  159.         private int numberofExtraLeaves;
  160.         public int NumberOfExtraLeaves
  161.         {
  162.             get { return numberofExtraLeaves; }
  163.             set { numberofExtraLeaves = value; }
  164.         }
  165.  
  166.  
  167.  
  168.         // Holidays and Deduction.
  169.         private int totalSalaryDudcted;   // no of extra leaves * one day salary
  170.         public int TotalSalaryDudcted
  171.         {
  172.             get { return totalSalaryDudcted; }
  173.             set { totalSalaryDudcted = value; }
  174.         }
  175.         private int oneDaySalary;
  176.         public int OneDaySalary
  177.         {
  178.             get { return oneDaySalary; }
  179.             set { oneDaySalary = value; }
  180.         }
  181.  
  182.         private int salaryAfterDeduction;
  183.         public int SalaryAfterDeduction
  184.         {
  185.             get { return salaryAfterDeduction; }
  186.             set { salaryAfterDeduction = value; }
  187.         }
  188.  
  189.        
  190.         public Attendance()
  191.         {
  192.  
  193.         }
  194.  
  195.         public Attendance(int numberofPaidLeaves, int numberofExtraLeaves)
  196.         {
  197.             this.NumberOfPaidLeaves = numberofPaidLeaves;
  198.             this.NumberOfExtraLeaves = numberofExtraLeaves;
  199.         }
  200.  
  201.  
  202.  
  203.         #region ---- FUNCTIONS ------
  204.  
  205.         public void ExecuteDeduction(employee e)
  206.         {
  207.             // leaves * one day salary
  208.  
  209.             // find one day salary.
  210.             e.EmpAttendance.OneDaySalary = e.EmpSal.B_sal / e.EmpAttendance.NumberOfWorkingDays;
  211.  
  212.             if(e.EmpAttendance.NumberOfExtraLeaves > 0)
  213.             {
  214.                 // find the total deduction
  215.                 e.EmpAttendance.TotalSalaryDudcted = e.EmpAttendance.NumberOfExtraLeaves * e.EmpAttendance.OneDaySalary;
  216.                 e.EmpAttendance.SalaryAfterDeduction = e.EmpSal.B_sal - e.EmpAttendance.TotalSalaryDudcted;
  217.             }
  218.         }
  219.  
  220.         public void ShowDeductionDetails(employee e)
  221.         {
  222.             Console.WriteLine("Total Working Days : " + e.EmpAttendance.NumberOfWorkingDays);
  223.             Console.WriteLine("Total Paid Leaves : " + e.EmpAttendance.NumberOfPaidLeaves);
  224.             Console.WriteLine("Total Extra Leaves : " + e.EmpAttendance.numberofExtraLeaves);
  225.             Console.WriteLine("OneDaySalary : " + e.EmpAttendance.OneDaySalary);
  226.             Console.WriteLine("Total Salary Deduction : " + e.EmpAttendance.TotalSalaryDudcted);
  227.             Console.WriteLine("Total Salary After Deduction : " + e.EmpAttendance.SalaryAfterDeduction);
  228.         }
  229.  
  230.  
  231.         #endregion  
  232.     }
  233.     public class salary : Attendance
  234.     {
  235.         private int b_sal;
  236.         public int B_sal
  237.         {
  238.             get { return b_sal; }
  239.             set { b_sal = value; }
  240.         }
  241.         private int ctc;
  242.         public int Ctc
  243.         {
  244.             get { return ctc; }
  245.             set { ctc = value; }
  246.         }
  247.  
  248.         public salary()
  249.         {
  250.             this.B_sal = 0;
  251.             this.Ctc = 0;
  252.         }
  253.  
  254.        
  255.  
  256.         public void DisplpayEmployeeSalary(employee a)
  257.         {
  258.             Console.WriteLine("Employee Base Salary : " + a.EmpSal.B_sal);
  259.             Console.WriteLine("Employee CTC : " + a.EmpSal.Ctc);
  260.         }
  261.  
  262.         public void SetSalaryByLevel(employee a)
  263.         {
  264.             if (a.EmpDesignation.Level == 1)
  265.             {
  266.                 a.EmpSal.Ctc = 1200000;
  267.                 a.EmpSal.B_sal = (a.EmpSal.Ctc / 12);
  268.             }
  269.  
  270.             if (a.EmpDesignation.Level == 2)
  271.             {
  272.                 a.EmpSal.Ctc = 2500000;
  273.                 a.EmpSal.B_sal = (a.EmpSal.Ctc / 12);
  274.             }
  275.  
  276.             if (a.EmpDesignation.Level == 3)
  277.             {
  278.                 a.EmpSal.Ctc = 4200000;
  279.                 a.EmpSal.B_sal = (a.EmpSal.Ctc / 12);
  280.             }
  281.         }
  282.  
  283.     }
  284.  
  285.  
  286.     public class Allowances :salary
  287.     {
  288.  
  289.         // make these private get and set all of them variables
  290.         private int houseallowancces;
  291.         public int Houseallowancces
  292.         {
  293.             get { return houseallowancces; }
  294.             set { houseallowancces = value; }
  295.         }
  296.         private int carloanallowance;
  297.         public int Carloanallowance
  298.         {
  299.             get { return carloanallowance; }
  300.             set { carloanallowance = value; }
  301.         }
  302.         // add more allowances
  303.         // if you want
  304.  
  305.         public Allowances()
  306.         {
  307.             // 0 is set because all these values will be Calculated based on the level of the person
  308.  
  309.             this.Houseallowancces = 0;
  310.             this.Carloanallowance = 0;
  311.         }
  312.  
  313.         public void Display_Employee_Allowances(employee a)
  314.         {
  315.             Console.WriteLine("Employee Car Loan Allowance : " + a.EmpAllw.Carloanallowance);
  316.             Console.WriteLine("Employee House Loan Allowance : " + a.EmpAllw.Houseallowancces);
  317.  
  318.         }
  319.  
  320.         public void AllowanceSetByLevel(employee a)
  321.         {
  322.             if (a.EmpDesignation.Level == 1)
  323.             {
  324.                 a.EmpAllw.Carloanallowance = 12000;
  325.                 a.EmpAllw.Houseallowancces = 18000;
  326.             }
  327.  
  328.             if (a.EmpDesignation.Level == 2)
  329.             {
  330.                 //sConsole.WriteLine("Running For Level 2");
  331.                 a.EmpAllw.Carloanallowance = 15000;
  332.                 a.EmpAllw.Houseallowancces = 20000;
  333.             }
  334.  
  335.             if (a.EmpDesignation.Level == 3)
  336.             {
  337.                 a.EmpAllw.Carloanallowance = 18000;
  338.                 a.EmpAllw.Houseallowancces = 22000;
  339.             }
  340.  
  341.         }
  342.     }
  343.     public class employee : Allowances
  344.     {
  345.         private int employeeid;
  346.         public int Employeeid
  347.         {
  348.             get { return employeeid; }
  349.             set { employeeid = value; }
  350.         }
  351.  
  352.         private string employeename;
  353.         public string Employeename
  354.         {
  355.             get { return employeename; }
  356.             set { employeename = value; }
  357.         }
  358.         private string employedate;
  359.         public string Employedate
  360.         {
  361.             get { return employedate; }
  362.             set { employedate = value; }
  363.         }
  364.         private salary emp_sal;
  365.         public salary EmpSal
  366.         {
  367.             get { return emp_sal; }
  368.             set
  369.             {
  370.                 emp_sal = value;
  371.             }
  372.         }
  373.         private Allowances emp_allw;
  374.         public Allowances EmpAllw
  375.         {
  376.             get { return emp_allw; }
  377.             set
  378.             {
  379.                 emp_allw = value;
  380.             }
  381.         }
  382.         private Designation emp_designation;
  383.         public Designation EmpDesignation
  384.         {
  385.             get { return emp_designation; }
  386.             set { emp_designation = value; }
  387.         }
  388.         private Attendance emp_attendance;
  389.         public Attendance EmpAttendance
  390.         {
  391.             get { return emp_attendance; }
  392.             set
  393.             {
  394.                 emp_attendance = value;
  395.             }
  396.         }
  397.  
  398.        
  399.  
  400.         public employee()
  401.         {
  402.  
  403.         }
  404.  
  405.  
  406.         public employee(int emp_id, string emp_name, string emp_date,salary emp_sal, Allowances emp_all, Designation emp_des, Attendance emp_att)
  407.         {
  408.             this.Employeeid =  emp_id;
  409.             this.Employeename = emp_name;
  410.             this.Employedate = emp_date;
  411.             this.EmpSal = emp_sal;
  412.             this.EmpAllw = emp_all;
  413.             this.EmpDesignation = emp_des;
  414.             this.EmpAttendance = emp_att;
  415.         }
  416.  
  417.         public void displayemployeedetails()
  418.         {
  419.             Console.WriteLine("employee name:" + this.Employeename);
  420.             Console.WriteLine("employee id:" + this.Employeeid);
  421.             Console.WriteLine("employee dateofbirth:" + this.Employedate);
  422.             Console.WriteLine("employee basesalary:" + this.EmpSal.B_sal);
  423.             Console.WriteLine("employee CTC:" + this.EmpSal.Ctc);
  424.             Console.WriteLine("employee houseallowances:" + this.EmpAllw.Houseallowancces);
  425.             Console.WriteLine("employee carallowances:" + this.EmpAllw.Carloanallowance);
  426.  
  427.         }
  428.  
  429.  
  430.         public void DisplayPaySlip(employee e)
  431.         {
  432.             // Call Few Functions to the prior.
  433.             // DO NOT TOUCH THE FUNCTIONS AT ALL
  434.             e.Designation_Set_By_Lvl(e);
  435.             e.SetSalaryByLevel(e);
  436.             e.AllowanceSetByLevel(e);
  437.             e.ExecuteDeduction(e);
  438.  
  439.  
  440.             Console.WriteLine("-----------------------------------------------------");
  441.             //// Implement payslip from here
  442.  
  443.             e.Display_Employee_Allowances(e);
  444.             e.DisplpayEmployeeSalary(e);
  445.             e.ShowDeductionDetails(e);
  446.            
  447.         }
  448.  
  449.  
  450.  
  451.         public void TakeInput(employee e)
  452.         {
  453.             // TAKE INPUT AND HANDLE EXCEPTION HANDLING HERE ONLY
  454.             // TAKE SEPERATE VARIABLES AND THEN TRY TO PASS THE VARIABLES IN THE CONTRUCTORS OF THE CLASSES. LIKE
  455.             // DONE IN THE MAIN FUNCTION
  456.         }
  457.  
  458.     }
  459.     public class Program
  460.     {
  461.         public static void Main()
  462.         {
  463.  
  464.             //// TO DO : DYNAMIC INPUT TAKING FROM USER
  465.             Attendance atn = new Attendance(5,5);
  466.             Designation ds = new Designation(2);
  467.             salary s = new salary();
  468.             Allowances al = new Allowances();
  469.  
  470.             employee e = new employee(1415, "Sucharita", "24/05/1999", s, al, ds, atn);
  471.  
  472.             e.DisplayPaySlip(e);
  473.  
  474.  
  475.            
  476.  
  477.  
  478.         }
  479.     }
  480.  
  481. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement