1700472547
public class ShowVisitor implements IShowVisitor{
1700472548
1700472549
private String info=””;
1700472550
1700472551
//打印出报表
1700472552
1700472553
public void report(){
1700472554
1700472555
System.out.println(this.info);
1700472556
1700472557
}
1700472558
1700472559
//访问普通员工,组装信息
1700472560
1700472561
public void visit(CommonEmployee commonEmployee){
1700472562
1700472563
this.info=this.info+this.getBasicInfo(commonEmployee)+“工作:
1700472564
1700472565
“+commonEmployee.getJob()+”\t\n”;
1700472566
1700472567
}
1700472568
1700472569
//访问经理,然后组装信息
1700472570
1700472571
public void visit(Manager manager){
1700472572
1700472573
this.info=this.info+this.getBasicInfo(manager)+“业绩:
1700472574
1700472575
“+manager.getPerformance()+”\t\n”;
1700472576
1700472577
}
1700472578
1700472579
//组装出基本信息
1700472580
1700472581
private String getBasicInfo(Employee employee){
1700472582
1700472583
String info=“姓名:”+employee.getName()+”\t”;
1700472584
1700472585
info=info+“性别:”+(employee.getSex()==Employee.FEMALE?“女”:“男
1700472586
1700472587
“)+”\t”;
1700472588
1700472589
info=info+“薪水:”+employee.getSalary()+”\t”;
1700472590
1700472591
return info;
1700472592
1700472593
}
1700472594
1700472595
}
1700472596
[
上一页 ]
[ :1.700472547e+09 ]
[
下一页 ]