1700471631
1700471632
public int getSalary(){
1700471633
1700471634
return salary;
1700471635
1700471636
}
1700471637
1700471638
public void setSalary(int salary){
1700471639
1700471640
this.salary=salary;
1700471641
1700471642
}
1700471643
1700471644
public int getSex(){
1700471645
1700471646
return sex;
1700471647
1700471648
}
1700471649
1700471650
public void setSex(int sex){
1700471651
1700471652
this.sex=sex;
1700471653
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所示。
[
上一页 ]
[ :1.700471631e+09 ]
[
下一页 ]