Java Design patterns

This commit is contained in:
Javadevjournal
2022-03-20 09:31:02 -07:00
parent aa5cb0a341
commit 3f49ebb6c0
52 changed files with 1080 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package javadevjournal.design.creational.factory;
/**
* @author Kunwar
* Factory Pattern Demo
*/
public class FactoryPatternDemo {
public static void main(String[] args) {
ShapeFactory shapeFactory = new ShapeFactory();
/* get an object of Circle Class and call its drawShape method. */
Shape shape1 = shapeFactory.getShape("CIRCLE");
shape1.drawShape();
/* get an object of Rectangle Class and call its drawShape method. */
Shape shape2 = shapeFactory.getShape("RECTANGLE");
shape2.drawShape();
/* get an object of Square Class and call its drawShape method. */
Shape shape3 = shapeFactory.getShape("SQUARE");
shape3.drawShape();
}
}