打字猴:1.700472447e+09
1700472447 private int commonTotalSalary=0;
1700472448
1700472449 //部门经理的工资总和
1700472450
1700472451 private int managerTotalSalary=0;
1700472452
1700472453 //计算部门经理的工资总和
1700472454
1700472455 private void calManagerSalary(int salary){
1700472456
1700472457 this.managerTotalSalary=this.managerTotalSalary+salary
1700472458
1700472459 *MANAGER_COEFFICIENT;
1700472460
1700472461 }
1700472462
1700472463 //计算普通员工的工资总和
1700472464
1700472465 private void calCommonSlary(int salary){
1700472466
1700472467 this.commonTotalSalary=this.commonTotalSalary+
1700472468
1700472469 salary*COMMONEMPLOYEE_COEFFICIENT;
1700472470
1700472471 }
1700472472
1700472473 //获得所有员工的工资总和
1700472474
1700472475 public int getTotalSalary(){
1700472476
1700472477 return this.commonTotalSalary+this.managerTotalSalary;
1700472478
1700472479 }
1700472480
1700472481 }
1700472482
1700472483 员工和经理层的信息就不再展示了,请参考代码清单25-6。程序还是比较简单的,分别计算普通员工和经理级员工的工资总和,然后加起来。注意,我们在实现时已经考虑员工工资和经理工资的系数不同。
1700472484
1700472485 我们再来看Client类的模拟,如代码清单25-19所示。
1700472486
1700472487 代码清单25-19 场景类
1700472488
1700472489 public class Client{
1700472490
1700472491 public static void main(String[]args){
1700472492
1700472493 IVisitor visitor=new Visitor();
1700472494
1700472495 for(Employee emp:mockEmployee()){
1700472496
[ 上一页 ]  [ :1.700472447e+09 ]  [ 下一页 ]