1700472047
public void setPerformance(String performance){
1700472048
1700472049
this.performance=performance;
1700472050
1700472051
}
1700472052
1700472053
//部门经理允许访问者访问
1700472054
1700472055
@Override
1700472056
1700472057
public void accept(IVisitor visitor){
1700472058
1700472059
visitor.visit(this);
1700472060
1700472061
}
1700472062
1700472063
}
1700472064
1700472065
所有的业务定义都已经完成,我们来看看怎么模拟这个逻辑,如代码清单25-10所示。
1700472066
1700472067
代码清单25-10 场景类
1700472068
1700472069
public class Client{
1700472070
1700472071
public static void main(String[]args){
1700472072
1700472073
for(Employee emp:mockEmployee()){
1700472074
1700472075
emp.accept(new Visitor());
1700472076
1700472077
}
1700472078
1700472079
}
1700472080
1700472081
//模拟出公司的人员情况,我们可以想象这个数据是通过持久层传递过来的
1700472082
1700472083
public static List<Employee>mockEmployee(){
1700472084
1700472085
List<Employee>empList=new ArrayList<Employee>();
1700472086
1700472087
//产生张三这个员工
1700472088
1700472089
CommonEmployee zhangSan=new CommonEmployee();
1700472090
1700472091
zhangSan.setJob(“编写Java程序,绝对的蓝领、苦工加搬运工”);
1700472092
1700472093
zhangSan.setName(“张三”);
1700472094
1700472095
zhangSan.setSalary(1800);
1700472096
[
上一页 ]
[ :1.700472047e+09 ]
[
下一页 ]