-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProxyPatternDemo.java
36 lines (25 loc) · 1.45 KB
/
ProxyPatternDemo.java
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
27
28
29
30
31
32
33
34
35
36
/*
This is a demonstration of Proxy Pattern.
When a client orders a product, first it will be searched on the local/district/proxy warehouse.
If the product exists there, it will be served from proxy warehouse.
Otherwise, the product will be delivered from global warehouse.
Besides, 2 new copy of the same product will be delivered to proxy warehouse for further use.
*/
public class ProxyPatternDemo {
public static void main(String[] args) {
DistrictProxyWarehouse districtwarehouse = new DistrictProxyWarehouse();
// 1st Order of Macbook Air - Delivered from Global Warehouse
// 2 copy of Macbook Air sent to Proxy Warehouse considering that people may buy it in future again.
districtwarehouse.deliverProduct("Macbook Air");
// 2nd Order of Macbook Air - Delivered from Proxy Warehouse
districtwarehouse.deliverProduct("Macbook Air");
// 3rd Order of Macbook Air - Delivered from Proxy Warehouse.
// No more Macbook Air available on Proxy Warehouse.
districtwarehouse.deliverProduct("Macbook Air");
// 4th Order of Macbook Air - Delivered from Global Warehouse.
// 2 copy of Macbook Air sent to Proxy Warehouse considering that people may buy it in future again.
districtwarehouse.deliverProduct("Macbook Air");
// 5th Order of Macbook Air - Delivered from Proxy Warehouse
districtwarehouse.deliverProduct("Macbook Air");
}
}