publicclassDazongfactoryimplementsfactory{@Overridepublic car getCar(){returnnewDazong();}}
publicclassWuliffactoryimplementsfactory{@Overridepublic car getCar(){returnnewWuli();}}
publicclassTest{publicstaticvoidmain(String[] args){// 普通模式/* car c = new Wuli();
car c2 = new Dazong();
c.name();
c2.name();*/// 使用方法工厂, 符合开闭原则newWuliffactory().getCar().name();newDazongfactory().getCar().name();}}