/*
FACADE DESIGN PATTERN IN JAVA
*/
class Client
{
public static void main(String args[]){
OrderFacade orderFacade = new OrderFacade();
orderFacade.placeOrder("OR123456");
System.out.println("Order processing completed");
}
}
class OrderFacade {
private Payment pymt = new Payment();
private Inventory inventry = new Inventory();
public void placeOrder(String orderId) {
String step1 = inventry.checkInventory(orderId);
String step2 = pymt.deductPayment(orderId);
System.out.println("Following steps completed:" + step1+ " & " + step2);
}
}
class Payment {
public String deductPayment(String orderID)
{
System.out.println("TOKEN "+orderID+" recieved\nProcessing payment...\n");
return "Payment deducted successfully";
}
}
class Inventory {
public String checkInventory(String OrderId)
{
System.out.println("TOKEN "+OrderId+" recieved\nProcessing Inventory...\n");
return "Inventory checked";
}
}
/*
OUTPUT:
TOKEN OR123456 recieved
Processing Inventory...
TOKEN OR123456 recieved
Processing payment...
Following steps completed:Inventory checked & Payment deducted successfully
Order processing completed
*/
No comments:
Post a Comment