001package factory.shape3; 002public class ShapeFactory { 003 private ShapeFactory() {} 004 static public Shape newInstance(String selector) { 005 if ("Ellipse".equals(selector)) return new Ellipse(); 006 if ("Circle".equals(selector)) return new Ellipse(); 007 if ("Rectangle".equals(selector)) return new Rectangle(); 008 if ("Square".equals(selector)) return new Rectangle(); 009 throw new IllegalArgumentException(); 010 } 011}