akifislam / Proxy-Design-Pattern

This repository demonstrates the Proxy Pattern where client's order will be served from global ware house or proxy warehouse depending on the product availability

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A demonstration of Proxy Pattern

Course Title : Object Oriented Design and Design Patterns Lab(CSE 4122)

Author

Akif Islam
Department of CSE, University of Rajshahi
iamakifislam@gmail.com


Experiment 05

Write a Java program to demonstrate the implementation of a proxy pattern for an online retail store with global distribution and warehousing.

Story of the Program

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.

Flowchart

How to Run?

  $javac ProxyPatternDemo.java
  $java ProxyPatternDemo

Proxy Pattern Demo Program

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");

Output

About

This repository demonstrates the Proxy Pattern where client's order will be served from global ware house or proxy warehouse depending on the product availability


Languages

Language:Java 100.0%