@@ -0,0 +1,999 @@
+package creational;%0A%0A/**%0A * Created by %E6%9D%8E%E6%81%92%E5%90%8D on 2017/6/14.%0A * %3Cp%3E%0A * %E7%AE%80%E5%8D%95%E5%B7%A5%E5%8E%82%E6%A8%A1%E5%BC%8F%0A */%0Apublic class SimpleFactoryPattern %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        CarFactory factory = new CarFactory();%0A        Car car = factory.getCar(%22Benz%22);%0A        //Car car = factory.getCar(%22BMW%22);%0A        car.run();%0A    %7D%0A%0A    static abstract class Car %7B%0A        abstract void run();%0A    %7D%0A%0A    static class Benz extends Car %7B%0A%0A        @Override%0A        void run() %7B%0A            System.out.println(%22%E5%A5%94%E9%A9%B0%E8%BD%A6%E5%9C%A8%E8%B7%91%22);%0A        %7D%0A    %7D%0A%0A    static class BMW extends Car %7B%0A%0A        @Override%0A        void run() %7B%0A            System.out.println(%22%E5%AE%9D%E9%A9%AC%E8%BD%A6%E5%9C%A8%E8%B7%91%22);%0A        %7D%0A    %7D%0A%0A    static class CarFactory %7B%0A        Car getCar(String name) %7B%0A            if (name.equals(%22Benz%22)) %7B%0A                return new Benz();%0A            %7D else if (name.equals(%22BMW%22)) %7B%0A                return new BMW();%0A            %7D else %7B%0A                throw new IllegalArgumentException(%22No support this car%22);%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A%0A

add > 简单工厂模式