Compare commits
2 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
1a6997c5c7 | 4 months ago |
|
|
38f2bb69f8 | 4 months ago |
@ -0,0 +1,6 @@
|
||||
public class ConcreteProductA implements Product {
|
||||
@Override
|
||||
public void operation() {
|
||||
System.out.println("ConcreteProductA operation");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
public class Factory {
|
||||
public static Product createProduct(String type) {
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
if (type.equalsIgnoreCase("A")) {
|
||||
return new ConcreteProductA();
|
||||
} else if (type.equalsIgnoreCase("B")) {
|
||||
return new ConcreteProductB();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue