Skip to content

Commit

Permalink
Small enhacements to Design patterns code snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
100yo committed Jan 10, 2024
1 parent 03de5dc commit ed8bd01
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public BuyStock(Stock abcStock) {
this.abcStock = abcStock;
}

@Override
public void execute() {
abcStock.buy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public class CommandPatternDemo {
public static void main(String[] args) {
Stock abcStock = new Stock();

BuyStock buyStockOrder = new BuyStock(abcStock);
SellStock sellStockOrder = new SellStock(abcStock);
Order buyStockOrder = new BuyStock(abcStock);
Order sellStockOrder = new SellStock(abcStock);

Broker broker = new Broker();
broker.takeOrder(buyStockOrder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public SellStock(Stock abcStock) {
this.abcStock = abcStock;
}

@Override
public void execute() {
abcStock.sell();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void main(String[] args) {
cart.pay(new PaypalStrategy("[email protected]", "mypwd"));

// pay by credit card
cart.pay(new CreditCardStrategy("Jeff Bezos", "1234567890123456", "786", "12/22"));
cart.pay(new CreditCardStrategy("Jeff Bezos", "1234567890123456", "786", "12/24"));
}

}

0 comments on commit ed8bd01

Please sign in to comment.