Exemple #1
0
        static void Main(string[] args)
        {
            var shippingCalculatorService = new ShippingCostCalculatorService();
            var fedExOrder        = OrderService.CreateFedExOrder();
            var fedExShippingCost = shippingCalculatorService.CalculateShippingCost(fedExOrder);

            Console.WriteLine($"FedEx Shipping Cost: {fedExShippingCost}");

            var upsOrder        = OrderService.CreateUPSOrder();
            var upsShippingCost = shippingCalculatorService.CalculateShippingCost(upsOrder);

            Console.WriteLine($"UPS Shipping Cost: {upsShippingCost}");


            var upsShippingOrderr = OrderService.CreateUSPSOrder();
            var uspsShippingCost  = shippingCalculatorService.CalculateShippingCost(upsShippingOrderr);

            Console.WriteLine($"USPS Shipping Cost: {uspsShippingCost}");
            Console.ReadKey();
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            Func <Order, double> fedExStrategy = CalcForFedEx;
            Func <Order, double> upsStrategy   = delegate(Order order) { return(4.00d); };
            Func <Order, double> uspsStrategy  = order => 3.25d;

            Order theOrder = Mother.CreateOrder();

            var calculatorService = new ShippingCostCalculatorService();

            Console.WriteLine("FedEx Shipping Cost: " +
                              calculatorService.CalculateShippingCost(theOrder, fedExStrategy));

            Console.WriteLine("UPS Shipping Cost: " +
                              calculatorService.CalculateShippingCost(theOrder, upsStrategy));

            Console.WriteLine("USPS Shipping Cost: " +
                              calculatorService.CalculateShippingCost(theOrder, uspsStrategy));

            Console.ReadKey();
        }