| 8 | import patterns.shapes.*; |
| 9 | |
| 10 | public class ShapeFactory1 implements FactoryMethod { |
| 11 | @Override public Shape create(String type) { |
| 12 | switch(type) { |
| 13 | case "Circle": return new Circle(); |
| 14 | case "Square": return new Square(); |
| 15 | case "Triangle": return new Triangle(); |
| 16 | default: |
| 17 | throw new BadShapeCreation(type); |
| 18 | } |
| 19 | } |
| 20 | public static void main(String[] args) { |
| 21 | FactoryTest.test(new ShapeFactory1()); |
| 22 | } |
| 23 | } |
| 24 | /* Output: |
| 25 | Circle[0] draw |
| 26 | Circle[0] erase |
nothing calls this directly
no outgoing calls
no test coverage detected