static void Main(string[] args) { Package package = new Package() { From = 76712, To = 10012, Weight = "1kg" }; // the 3 strategies UPS ups = new UPS(); USPS usps = new USPS(); Fedex fedex = new Fedex(); Shipping shipping = new Shipping(); shipping.SetStrategy(ups); Console.WriteLine("UPS Strategy: " + shipping.Calculate(package)); shipping.SetStrategy(usps); Console.WriteLine("USPS Strategy: " + shipping.Calculate(package)); shipping.SetStrategy(fedex); Console.WriteLine("Fedex Strategy: " + shipping.Calculate(package)); }
static void Main(string[] args) { Package package = new Package() { From = 76712, To = 10012, Weight = "1kg"}; // the 3 strategies UPS ups = new UPS(); USPS usps = new USPS(); Fedex fedex = new Fedex(); Shipping shipping = new Shipping(); shipping.SetStrategy(ups); Console.WriteLine("UPS Strategy: " + shipping.Calculate(package)); shipping.SetStrategy(usps); Console.WriteLine("USPS Strategy: " + shipping.Calculate(package)); shipping.SetStrategy(fedex); Console.WriteLine("Fedex Strategy: " + shipping.Calculate(package)); }