class ComSalary ????{ ????????//老板的薪水计算:薪水=基础工资+项目奖金+分红 ????????public static int Pay(PM pm) ????????{ ????????????return pm.BasePay + pm.MeritPay + pm.Bonus; ????????} ????????//个人的薪水计算:薪水=基础工资+项目奖金 ????????public static int Pay(SE se) ????????{ ????????????return se.BasePay + se.MeritPay; ????????} } ????? static void Main(string[] args) ????????{ ?//实例化一个(个人)对象 ????????????SE tom = new SE { ?Id="998", Name="汤姆", BasePay=6000, MeritPay=1000}; //实例化一个(老板)对象 ????????????PM jack = new PM { Id = "110", Name = "杰克", BasePay = 9000, MeritPay = 2000, Bonus=1500}; ????????????//计算工资 ????????????Console.WriteLine("个人的薪水:"+ComSalary.Pay(tom)); ????????????Console.WriteLine("老板的薪水:" + ComSalary.Pay(jack)); ????????} |