Skip to content

Instantly share code, notes, and snippets.

Last active January 4, 2021 17:09
What would you like to do?
public class ShapeFactory {
public Shape getShape(String shape) {
if (shape.equalsIgnoreCase("Circle"))
return new Circle();
else if (shape.equalsIgnoreCase("Rectangle"))
return new Rectangle();
else if (shape.equalsIgnoreCase("Square"))
return new Square();
return null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment