1700471654
}
1700471655
1700471656
//打印出员工的信息
1700471657
1700471658
public final void report(){
1700471659
1700471660
String info=“姓名:”+this.name+”\t”;
1700471661
1700471662
info=info+“性别:”+(this.sex==FEMALE?“女”:“男”)+”\t”;
1700471663
1700471664
info=info+“薪水:”+this.salary+”\t”;
1700471665
1700471666
//获得员工的其他信息
1700471667
1700471668
info=info+this.getOtherInfo();
1700471669
1700471670
System.out.println(info);
1700471671
1700471672
}
1700471673
1700471674
//拼装员工的其他信息
1700471675
1700471676
protected abstract String getOtherInfo();
1700471677
1700471678
}
1700471679
1700471680
先看小兵的实现类,越卑微的人物越能引起共鸣,因为我们有共同的经历、思维和苦难。请看实现类,如代码清单25-2所示。
1700471681
1700471682
代码清单25-2 普通员工
1700471683
1700471684
public class CommonEmployee extends Employee{
1700471685
1700471686
//工作内容,这非常重要,以后的职业规划就是靠它了
1700471687
1700471688
private String job;
1700471689
1700471690
public String getJob(){
1700471691
1700471692
return job;
1700471693
1700471694
}
1700471695
1700471696
public void setJob(String job){
1700471697
1700471698
this.job=job;
1700471699
1700471700
}
1700471701
1700471702
protected String getOtherInfo(){
1700471703
[
上一页 ]
[ :1.700471654e+09 ]
[
下一页 ]