Beispiel #1
0
            // 实现人力资源部对全职员工数据的访问
            public override void Visit(FullTimeEmployee employee)
            {
                int workTime = employee.WorkTime;

                Console.WriteLine("正式员工 {0} 实际工作时间为:{1} 小时", employee.Name, workTime);

                if (workTime > 40)
                {
                    Console.WriteLine("正式员工 {0} 加班时间为:{1} 小时", employee.Name, workTime - 40);
                }
                else if (workTime < 40)
                {
                    Console.WriteLine("正式员工 {0} 请假时间为:{1} 小时", employee.Name, 40 - workTime);
                }
            }
Beispiel #2
0
            // 实现财务部对全职员工数据的访问
            public override void Visit(FullTimeEmployee employee)
            {
                int    workTime = employee.WorkTime;
                double weekWage = employee.WeeklyWage;

                if (workTime > 40)
                {
                    weekWage = weekWage + (workTime - 40) * 50;
                }
                else if (workTime < 40)
                {
                    weekWage = weekWage - (40 - workTime) * 80;
                    if (weekWage < 0)
                    {
                        weekWage = 0;
                    }
                }

                Console.WriteLine("正式员工 {0} 实际工资为:{1} 元", employee.Name, weekWage);
            }
Beispiel #3
0
            public static void Main(string[] args)
            {
                EmployeeList empList = new EmployeeList();
                IEmployee    fteA    = new FullTimeEmployee("梁思成", 3200.00, 45);
                IEmployee    fteB    = new FullTimeEmployee("徐志摩", 2000, 40);
                IEmployee    fteC    = new FullTimeEmployee("梁徽因", 2400, 38);
                IEmployee    fteD    = new PartTimeEmployee("方鸿渐", 80, 20);
                IEmployee    fteE    = new PartTimeEmployee("唐宛如", 60, 18);

                empList.AddEmployee(fteA);
                empList.AddEmployee(fteB);
                empList.AddEmployee(fteC);
                empList.AddEmployee(fteD);
                empList.AddEmployee(fteE);

                Department dept = AppConfigHelper.GetDeptInstance() as Department;

                if (dept != null)
                {
                    empList.Accept(dept);
                }

                Console.ReadKey();
            }
Beispiel #4
0
 // 声明一组重载的访问方法,用于访问不同类型的具体元素
 public abstract void Visit(FullTimeEmployee employee);