Example #1
0
        static void Main(string[] args)
        {
            Payroll payroll = new Payroll();

            payroll.Add("John Smith", 30000);
            payroll.Add("Susana Smith", 35000);
            payroll.Add("Rebecca Smith", 38500);

            Console.WriteLine("Enter a new employee and salary, Quit with Q");

            do
            {
                string name = Util.AskForString("Name: ");
                if (name == "Q")
                {
                    break;
                }
                int salary = Util.AskForInt("Salary: ");

                payroll.Add(name, salary);
            }while (true);


            foreach (var item in payroll.GetEmployees())
            {
                Console.WriteLine(item);

                switch (item.SalaryLevel)
                {
                case SalaryLevel.Junior:
                    Console.WriteLine("Do Junior Work");
                    break;

                case SalaryLevel.Senior:
                    Console.WriteLine("Do Senior Work");
                    break;

                default:
                    break;
                }
                Console.WriteLine("---------------------------");
            }
        }
Example #2
0
        private static void Print()
        {
            Employee[] employees = payroll.GetEmployees();

            foreach (Employee employee in employees)
            {
                Console.WriteLine(employee);

                //if (employee.SalaryLevel.Equals(SalaryLevel.Junior))
                //{
                //    Console.WriteLine(DoJuniorWork());
                //}
                //if (employee.SalaryLevel.Equals(SalaryLevel.Senior))
                //{
                //    Console.WriteLine(DoSeniorWork());
                //}

                Console.WriteLine(employee.SalaryLevel.Equals(SalaryLevel.Junior) ?
                                  DoJuniorWork() :
                                  DoSeniorWork());
            }
        }