Wednesday, 4 July 2018
Design Patterns - Facade Pattern
Subscribe to:
Post Comments (Atom)

public interface Shape { void draw(); }
public class Rectangle implements Shape { @Override public void draw() { System.out.println("Rectangle::draw()"); } }
public class Square implements Shape { @Override public void draw() { System.out.println("Square::draw()"); } }
public class Circle implements Shape { @Override public void draw() { System.out.println("Circle::draw()"); } }
public class ShapeMaker { private Shape circle; private Shape rectangle; private Shape square; public ShapeMaker() { circle = new Circle(); rectangle = new Rectangle(); square = new Square(); } public void drawCircle(){ circle.draw(); } public void drawRectangle(){ rectangle.draw(); } public void drawSquare(){ square.draw(); } }
public class FacadePatternDemo { public static void main(String[] args) { ShapeMaker shapeMaker = new ShapeMaker(); shapeMaker.drawCircle(); shapeMaker.drawRectangle(); shapeMaker.drawSquare(); } }
Circle::draw() Rectangle::draw() Square::draw()
Mumbai Academics Is Mumbai’s First Dedicated Professional Training Center For Training With Spoke And Hub Model With Multiple Verticles . The Strong Foundation Of Mumbai Academics Is Laid By Highly Skilled And Trained Professionals, Carrying Mission To Provide Industry Level Input To The Freshers And Highly Skilled And Trained Software Professionals/Other Professional To IT Companies.
Learn More →
No comments:
Post a Comment