打字猴:1.700472597e+09
1700472597 汇总表实现数据汇总功能,其接口如代码清单25-22所示。
1700472598
1700472599 代码清单25-22 汇总表接口
1700472600
1700472601 public interface ITotalVisitor extends IVisitor{
1700472602
1700472603 //统计所有员工工资总和
1700472604
1700472605 public void totalSalary();
1700472606
1700472607 }
1700472608
1700472609 就一句话,非常简单,我们再来看具体的汇总表访问者,如代码清单25-23所示。
1700472610
1700472611 代码清单25-23 具体汇总表
1700472612
1700472613 public class TotalVisitor implements ITotalVisitor{
1700472614
1700472615 //部门经理的工资系数是5
1700472616
1700472617 private final static int MANAGER_COEFFICIENT=5;
1700472618
1700472619 //员工的工资系数是2
1700472620
1700472621 private final static int COMMONEMPLOYEE_COEFFICIENT=2;
1700472622
1700472623 //普通员工的工资总和
1700472624
1700472625 private int commonTotalSalary=0;
1700472626
1700472627 //部门经理的工资总和
1700472628
1700472629 private int managerTotalSalary=0;
1700472630
1700472631 public void totalSalary(){
1700472632
1700472633 System.out.println(“本公司的月工资总额是”+(this.commonTotalSalary+
1700472634
1700472635 this.managerTotalSalary));
1700472636
1700472637 }
1700472638
1700472639 //访问普通员工,计算工资总额
1700472640
1700472641 public void visit(CommonEmployee commonEmployee){
1700472642
1700472643 this.commonTotalSalary=this.commonTotalSalary+commonEmployee.getSalary()
1700472644
1700472645 *COMMONEMPLOYEE_COEFFICIENT;
1700472646
[ 上一页 ]  [ :1.700472597e+09 ]  [ 下一页 ]