Last active
February 2, 2016 17:07
-
-
Save alincc/6edd7528fdd73d92a792 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Facade | |
// Intent: wrap a complex subsystem with a simpler interface | |
class Payment | |
{ | |
public void deduct(int orderId) | |
{ | |
System.out.println("Payment check"); | |
} | |
} | |
class Inventory | |
{ | |
public void check(int orderId) | |
{ | |
System.out.println("Inventory check"); | |
} | |
} | |
// Facade class | |
class OrderFacade | |
{ | |
private Payment payment = new Payment(); | |
private Inventory inventory = new Inventory(); | |
public void place(int orderId) | |
{ | |
inventory.check(orderId); | |
payment.deduct(orderId); | |
} | |
} | |
public class Main | |
{ | |
public static void main(String[] args) | |
{ | |
OrderFacade order = new OrderFacade(); | |
order.place(123123); | |
System.out.println("Order completed"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment