Skip to content

Instantly share code, notes, and snippets.

@iyengarajay
Last active April 10, 2017 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iyengarajay/c3635a7b627f7cf4c8f4d2529ea686a4 to your computer and use it in GitHub Desktop.
Save iyengarajay/c3635a7b627f7cf4c8f4d2529ea686a4 to your computer and use it in GitHub Desktop.
//Client
public class CommandPatternDemo {
public static void main(String[] args) {
//Stock
Stock abcStock = new Stock();
Broker broker = new Broker();
broker.takeOrder(() -> abcStock.buy());
broker.takeOrder(() -> abcStock.sell());
//Bond
Bond bond = new Bond();
broker.takeOrder(() -> bond.buyBonds());
broker.takeOrder(() -> bond.sellBonds());
broker.placeOrders();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment