Skip to content

Instantly share code, notes, and snippets.

@anjanashankar9
Last active January 4, 2021 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anjanashankar9/4073d9bbd2805776bd3e18b6dd896ddb to your computer and use it in GitHub Desktop.
Save anjanashankar9/4073d9bbd2805776bd3e18b6dd896ddb to your computer and use it in GitHub Desktop.
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