Пример #1
0
        /*private static readonly string[] input = {"Cake", "Cake", "Cake", "Cake", "Bread", "Bread", "Bread", "Bread", "Apple", "Apple", "Apple", "Apple", "Apple", "Apple"};*/

        static void Main(string[] args)
        {
            // TO MANUAL ENTER UNCOMMENT THIS

            /*ShoppingCart shoppingCart = GetShoppingCart(input);
             *
             * var config = GetConfig(CONFIG_FILE_NAME);
             * var priceList = new PriceList(config.GetPrices());
             * var bill = GenerateBill(config, priceList, shoppingCart);
             *
             * BillPrinter pr = new BillPrinter();
             * pr.print(bill, shoppingCart, priceList);*/

            // AND COMMENT BELOW
            if (args == null)
            {
                Console.WriteLine("Args is null");
            }
            else
            {
                ShoppingCart.ShoppingCart shoppingCart = GetShoppingCart(args);

                var config    = GetConfig();
                var priceList = new PriceList(config.GetPrices());
                var bill      = GenerateBill(config, priceList, shoppingCart);

                BillPrinter pr = new BillPrinter();
                pr.print(OUTPUT_BILL_FILE_NAME, bill, shoppingCart, priceList);
            }
        }
Пример #2
0
        private static Bill GenerateBill(Root config, PriceList priceList, ShoppingCart.ShoppingCart shoppingCart)
        {
            MainOfferHandler mainOfferHandler = new MainOfferHandler(config.GetOffers(), priceList);
            BillGenerator    billGenerator    = new BillGenerator(priceList, mainOfferHandler);
            Bill             bill             = billGenerator.GenerateBill(shoppingCart);

            return(bill);
        }
Пример #3
0
 private static ShoppingCart.ShoppingCart GetShoppingCart(String[] args)
 {
     ShoppingCart.ShoppingCart shoppingCart = new ShoppingCart.ShoppingCart();
     shoppingCart.AddItems(args.ToList());
     return(shoppingCart);
 }