Example #1
0
        public TestCaseResult GetResultForCase3()
        {
            //        Input 3:
            //        1 imported bottle of perfume at 27.99
            //        1 bottle of perfume at 18.99
            //        1 packet of headache pills at 9.75
            //        1 box of imported chocolates at 11.25

            //        Output 3:
            //        1 imported bottle of perfume: 32.19
            //        1 bottle of perfume: 20.89
            //        1 packet of headache pills: 9.75
            //        1 imported box of chocolates: 11.85
            //        Sales Taxes: 6.70
            //        Total: 74.68

            ShoppingCart shoppingCart = new ShoppingCart(taxationstrategy);

            Good importGood1 = new ImportedGood(new GoodFactory(GoodType.GENERIC).getGood("imported bottle of perfume", 27.99M));
            Good normalGood1 = new GoodFactory(GoodType.GENERIC).getGood("bottle of perfume", 18.99M);
            Good normalGood2 = new GoodFactory(GoodType.MEDICAL).getGood("packet of headache pills", 9.75M);
            Good importGood2 = new ImportedGood(new GoodFactory(GoodType.FOOD).getGood("imported box of chocolates", 11.25M));

            shoppingCart.add(1, importGood1);
            shoppingCart.add(1, normalGood1);
            shoppingCart.add(1, normalGood2);
            shoppingCart.add(1, importGood2);
            shoppingCart.printReceipt();

            return(new TestCaseResult()
            {
                Taxes = shoppingCart.getSalesTaxes(),
                TotalPrice = shoppingCart.getTotalPrice()
            });
        }
Example #2
0
        public TestCaseResult GetResultForCase2()
        {
            //        Input 2:
            //        1 imported box of chocolates at 10.00
            //        1 imported bottle of perfume at 47.50

            //        Output 2:
            //        1 imported box of chocolates: 10.50
            //        1 imported bottle of perfume: 54.65
            //        Sales Taxes: 7.65
            //        Total: 65.15
            ShoppingCart shoppingCart = new ShoppingCart(taxationstrategy);

            Good importGood1 = new ImportedGood(new GoodFactory(GoodType.FOOD).getGood("imported box of chocolates", 10.00M));
            Good importGood2 = new ImportedGood(new GoodFactory(GoodType.GENERIC).getGood("imported bottle of perfume", 47.50M));
            Good book        = new GoodFactory(GoodType.BOOK).getGood("book", 12.49M);

            shoppingCart.add(1, importGood1);
            shoppingCart.add(1, importGood2);

            shoppingCart.printReceipt();

            return(new TestCaseResult()
            {
                Taxes = shoppingCart.getSalesTaxes(),
                TotalPrice = shoppingCart.getTotalPrice()
            });
        }