diff --git a/notes/设计模式.md b/notes/设计模式.md index 8c9f0b22..c177ff92 100644 --- a/notes/设计模式.md +++ b/notes/设计模式.md @@ -276,6 +276,7 @@ public class ConcreteProduct2 implements Product { ```java public class Client { + public static void main(String[] args) { int type = 1; Product product; @@ -295,6 +296,7 @@ public class Client { ```java public class SimpleFactory { + public Product createProduct(int type) { if (type == 1) { return new ConcreteProduct1(); @@ -308,6 +310,7 @@ public class SimpleFactory { ```java public class Client { + public static void main(String[] args) { SimpleFactory simpleFactory = new SimpleFactory(); Product product = simpleFactory.createProduct(1);