now i have three class which i use to ship and those are Purolator, UPS and FedEx and each function has one common method which is Ship. now tell me how to use factory design pattern to make my code more reusable.
here is my sample code
--------------------------------
- public class Purolator
- {
- public void Ship()
- {
-
- }
- }
-
- public class UPS
- {
- public void Ship()
- {
-
- }
- }
-
- public class FexEx
- {
- public void Ship()
- {
-
- }
- }
now i create class instance by name separately when i require to use UPS or FedEx etc but how could i use factory design pattern to make my shipping business logic more reusable. please discuss it with a example code. thanks