抽象工厂模式:处理不同产品等级的对象(产品族)

public interface Human {
  public void getSound();
  public void getColor();
  public void getSex();
}

public abstract class BlackHuman implements Human{

  @Override

  public void getSound() {
    System.out.println("黑人说黑话");
  }

  @Override
  public void getColor() {
    System.out.println("黑人是黑色的");
  }
}

public class BlackMaleHuman extends BlackHuman{

  @Override
  public void getSex() {
     System.out.println("此乃黑男");
  }

}

public class BlackFeMaleHuman extends BlackHuman{

  @Override
  public void getSex() {
     System.out.println("此乃黑女");
  }

}

public abstract class WhiteHuman implements Human {

  @Override
  public void getSound() {
     System.out.println("白人说白话");
  }

  @Override
  public void getColor() {
     System.out.println("白人是白色的");
  }

}

public class WhiteFeMaleHuman extends WhiteHuman {

  @Override
  public void getSex() {
    System.out.println("此乃白女");
  }
}

public class WhiteMaleHuman extends WhiteHuman {

  @Override
  public void getSex() {
    System.out.println("此乃白男");
  }
}

public abstract class YellowHuman implements Human{

  @Override
  public void getSound() {
    System.out.println("黄人说黄话");
  }

  @Override
  public void getColor() {
     System.out.println("黄人是黄色的");
  }
}

public class YellowFeMaleHuman extends YellowHuman{

  @Override
  public void getSex() {
     System.out.println("此乃黄女");
  }

}

public class YellowMaleHuman extends YellowHuman{

  @Override
  public void getSex() {
     System.out.println("此乃黄男");
  }

}

public interface AbstractFac {
  public BlackHuman newBlack();
  public WhiteHuman newWhite();
  public YellowHuman newYellow();
}

public class FeMaleFac implements AbstractFac {

  @Override
  public BlackHuman newBlack() {
    return new BlackFeMaleHuman();
  }

  @Override
  public WhiteHuman newWhite() {
    return new WhiteFeMaleHuman();
  }

  @Override
  public YellowHuman newYellow() {
     return new YellowFeMaleHuman();
  }

}

public class MaleFac implements AbstractFac {

  @Override
  public BlackHuman newBlack() {
     return new BlackMaleHuman();
  }

  @Override
  public WhiteHuman newWhite() {
     return new WhiteMaleHuman();
  }

  @Override
  public YellowHuman newYellow() {
     return new YellowMaleHuman();
  }

}