打字猴:1.700468746e+09
1700468746
1700468747 return info;
1700468748
1700468749 }
1700468750
1700468751 //设置父节点
1700468752
1700468753 protected void setParent(Corp_parent){
1700468754
1700468755 this.parent=_parent;
1700468756
1700468757 }
1700468758
1700468759 //得到父节点
1700468760
1700468761 public Corp getParent(){
1700468762
1700468763 return this.parent;
1700468764
1700468765 }
1700468766
1700468767 }
1700468768
1700468769 就增加了粗体部分,然后我们再来看看树枝节点的改变,如代码清单21-26所示。
1700468770
1700468771 代码清单21-26 树枝构件
1700468772
1700468773 public class Branch extends Corp{
1700468774
1700468775 //领导下边有那些下级领导和小兵
1700468776
1700468777 ArrayList<Corp>subordinateList=new ArrayList<Corp>();
1700468778
1700468779 //构造函数是必须的
1700468780
1700468781 public Branch(String_name,String_position,int_salary){
1700468782
1700468783 super(_name,_position,_salary);
1700468784
1700468785 }
1700468786
1700468787 //增加一个下属,可能是小头目,也可能是个小兵
1700468788
1700468789 public void addSubordinate(Corp corp){
1700468790
1700468791 corp.setParent(this);//设置父节点
1700468792
1700468793 this.subordinateList.add(corp);
1700468794
1700468795 }
[ 上一页 ]  [ :1.700468746e+09 ]  [ 下一页 ]