public override double Calculate(Package package) { // calculations... return 39.40; }
public double Calculate(Package package) { return company.Calculate(package); }
public abstract double Calculate(Package 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)); }