打字猴:1.70045806e+09
1700458060 public Human createWhiteHuman(){
1700458061
1700458062 return new MaleWhiteHuman();
1700458063
1700458064 }
1700458065
1700458066 //生产出黄人男性
1700458067
1700458068 public Human createYellowHuman(){
1700458069
1700458070 return new MaleYellowHuman();
1700458071
1700458072 }
1700458073
1700458074 }
1700458075
1700458076 人种有了,八卦炉也有了,我们就来重现一下当年女娲造人的光景,如代码清单9-10所示。
1700458077
1700458078 代码清单9-10 女娲重造人类
1700458079
1700458080 public class NvWa{
1700458081
1700458082 public static void main(String[]args){
1700458083
1700458084 //第一条生产线,男性生产线
1700458085
1700458086 HumanFactory maleHumanFactory=new MaleFactory();
1700458087
1700458088 //第二条生产线,女性生产线
1700458089
1700458090 HumanFactory femaleHumanFactory=new FemaleFactory();
1700458091
1700458092 //生产线建立完毕,开始生产人了:
1700458093
1700458094 Human maleYellowHuman=maleHumanFactory.createYellowHuman();
1700458095
1700458096 Human femaleYellowHuman=femaleHumanFactory.createYellowHuman();
1700458097
1700458098 System.out.println(”–生产一个黄色女性–”);
1700458099
1700458100 femaleYellowHuman.getColor();
1700458101
1700458102 femaleYellowHuman.talk();
1700458103
1700458104 femaleYellowHuman.getSex();
1700458105
1700458106 System.out.println(”\n–生产一个黄色男性–”);
1700458107
1700458108 maleYellowHuman.getColor();
1700458109
[ 上一页 ]  [ :1.70045806e+09 ]  [ 下一页 ]