-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
26 lines (21 loc) · 690 Bytes
/
Copy pathMain.java
File metadata and controls
26 lines (21 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import decorator.*;
import decorator.impl.BasePizza;
import decorator.impl.Chicken;
import decorator.impl.Olive;
import decorator.impl.Pepperoni;
public class Main {
public static void main(String[] args) {
// can use Builder or Factory to construct this chain in real world for cleaner
Pizza pizza = new BasePizza();
display(pizza);
pizza = new Pepperoni(pizza);
display(pizza);
pizza = new Chicken(pizza);
display(pizza);
pizza = new Olive(pizza);
display(pizza);
}
public static void display(Pizza pizza) {
System.out.println(pizza.getDescription() + " costs $" + pizza.getCost());
}
}