You will give this task to the building contractor who will manage these things in a better manner. You’ll pay him 5,00,000 Rupees to that contractor, and you will explain him with your ideas. Then that contractor will handle these complicated things on behalf of us.
public interface Menu { public void showMenu(); }
public class VegMenu implements Menu { @Override public void showMenu() { System.out.println("Idly"); System.out.println("Dosa"); System.out.println("Vada"); } }
public class NonVegMenu implements Menu { @Override public void showMenu() { System.out.println("Chicken Biriyani"); System.out.println("Tandoori"); } }
public class HotleServiceStaff { private VegMenu vegMenu; private NonVegMenu nonVegMenu; public HotleServiceStaff() { this.vegMenu=new VegMenu(); this.nonVegMenu=new NonVegMenu(); } public void showVegMenu() { this.vegMenu.showMenu(); } public void showNonVegMenu() { this.nonVegMenu.showMenu(); } public void showVegNonVegMenu() { this.vegMenu.showMenu(); this.nonVegMenu.showMenu(); } }
public class FacadeEx { public static void main(String[] args) { HotleServiceStaff hotleServiceStaff=new HotleServiceStaff(); System.out.println("Veg Menu"); hotleServiceStaff.showVegMenu(); System.out.println("--------"); System.out.println("Non Veg Menu"); hotleServiceStaff.showNonVegMenu(); System.out.println("--------"); System.out.println("Veg & Non Veg Menu"); hotleServiceStaff.showVegNonVegMenu(); } }