Exemple #1
0
        public void CalculatePay()
        {
            foreach (PayrollEmployee person in this.Allemployees)
            {
                if (person is PayrollDeveloper)
                {
                    Console.WriteLine("This employee is a developer with employeeID: " + person.EmployeeID + ", please enter their bonus amount: ");
                    string val      = Console.ReadLine();
                    double inputVal = double.Parse(val);

                    PayrollDeveloper myEmp = (PayrollDeveloper)person;
                    myEmp.RecieveBonus(inputVal);
                    myEmp.PayInsurance();
                }

                else if (person is PayrollExecutive)
                {
                    Console.WriteLine("This employee is an executive, please enter their bonus amount: ");
                    string           val      = Console.ReadLine();
                    double           inputVal = double.Parse(val);
                    PayrollExecutive myEmp    = (PayrollExecutive)person;
                    myEmp.RecieveBonus(inputVal);
                    myEmp.PayInsurance();
                }
                else if (person is PayrollSales)
                {
                    Console.WriteLine("This employee is salesman, please enter their bonus amount: ");
                    string       val      = Console.ReadLine();
                    double       inputVal = double.Parse(val);
                    PayrollSales myEmp    = (PayrollSales)person;
                    myEmp.GiveEmployeeBonus(inputVal);
                }
                else if (person is PayrollHourly)
                {
                    Console.WriteLine("This emplyee is hourly, please enter hours worked: ");
                    string val         = Console.ReadLine();
                    int    hoursWorked = int.Parse(val);

                    PayrollHourly myEmp = (PayrollHourly)person;
                    myEmp.SetHoursWorked(hoursWorked);
                    myEmp.SetHourlyRate(20);
                }



                person.SetPaycheckTotal();
            }

            Console.WriteLine("ALl Employees total will now be calculated which will take a moment to compute!!");
            System.Threading.Thread.Sleep(1000);
            Console.WriteLine("All employee data was entered... The total will now be calculated");
        }