Exemplo n.º 1
0
        public IShoppingBag GetShoppingBagThatHaveNothingFurnitureProduct()
        {
            IShoppingBag shoppingBag = new ShoppingBag();

            shoppingBag.AddProduct(new Product(ProductName.Book, 159));
            shoppingBag.AddProduct(new Product(ProductName.Medicine, 180));
            return(shoppingBag);
        }
Exemplo n.º 2
0
        public IShoppingBag GetShoppingBagHaveNothingMedicineProduct()
        {
            IShoppingBag shoppingBag = new ShoppingBag();

            shoppingBag.AddProduct(new Product(ProductName.Book, 159));
            shoppingBag.AddProduct(new Product(ProductName.Snack, 100));
            return(shoppingBag);
        }
Exemplo n.º 3
0
        public IShoppingBag GetShoppingBagThatHaveFurnitureProductTotalCostIs300()
        {
            IShoppingBag shoppingBag = new ShoppingBag();

            shoppingBag.AddProduct(new Product(ProductName.Furniture, 300));
            shoppingBag.AddProduct(new Product(ProductName.Book, 159));
            shoppingBag.AddProduct(new Product(ProductName.Medicine, 180));
            return(shoppingBag);
        }
Exemplo n.º 4
0
        public IShoppingBag GetShoppingBagHave800TotalMedicineProductCost()
        {
            IShoppingBag shoppingBag = new ShoppingBag();

            shoppingBag.AddProduct(new Product(ProductName.Medicine, 400));
            shoppingBag.AddProduct(new Product(ProductName.Book, 159));
            shoppingBag.AddProduct(new Product(ProductName.Medicine, 400));
            shoppingBag.AddProduct(new Product(ProductName.Snack, 100));
            return(shoppingBag);
        }
Exemplo n.º 5
0
        public IShoppingBag GetShoppingBag(int totalSnackProduct, double productCost)
        {
            IShoppingBag shoppingBag = new ShoppingBag();

            shoppingBag.AddProduct(new Product(ProductName.KitchenEquipment, 195.50));
            shoppingBag.AddProduct(new Product(ProductName.Furniture, 150));

            for (int i = 0; i < totalSnackProduct; i++)
            {
                shoppingBag.AddProduct(new Product(ProductName.Snack, productCost));
            }

            return(shoppingBag);
        }
Exemplo n.º 6
0
        public IShoppingBag GetShoppingBag(int totalSnackProduct, double totalFurnitureCost)
        {
            var shoppingBag = new ShoppingBag();

            shoppingBag.AddProduct(new Product(ProductName.Book, 150));
            shoppingBag.AddProduct(new Product(ProductName.Furniture, totalFurnitureCost));
            shoppingBag.AddProduct(new Product(ProductName.Medicine, _medicineCostForDiscountPromotionTest));
            shoppingBag.AddProduct(new Product(ProductName.KitchenEquipment, 100));

            for (int i = 0; i < totalSnackProduct; i++)
            {
                shoppingBag.AddProduct(new Product(ProductName.Snack, _snackCostForDiscountPromotionTest));
            }

            return(shoppingBag);
        }
Exemplo n.º 7
0
    public static void Main()
    {
        var shoppingBag = new ShoppingBag();

        var n = int.Parse(Console.ReadLine());

        for (int i = 0; i < n; i++)
        {
            var input   = Console.ReadLine();
            var command = input.Split()[0];
            var args    = input.Replace($"{command}", "").Trim();
            var tokens  = args.Split(';');

            switch (command)
            {
            case "AddProduct":
                var product = new Product(tokens[0], decimal.Parse(tokens[1]), tokens[2]);
                shoppingBag.AddProduct(product);
                Console.WriteLine("Product added");
                break;

            case "DeleteProducts":
                Console.WriteLine(!args.Contains(";")
                        ? shoppingBag.DeleteProducts(args)
                        : shoppingBag.DeleteProducts(tokens[0], tokens[1]));
                break;

            case "FindProductsByName":
                var result = shoppingBag.FindProductsByName(args);
                if (result.Any())
                {
                    Console.WriteLine(string.Join(Environment.NewLine, result));
                    break;
                }

                Console.WriteLine("No products found");
                break;

            case "FindProductsByProducer":
                result = shoppingBag.FindProductsByProducer(args);
                if (result.Any())
                {
                    Console.WriteLine(string.Join(Environment.NewLine, result));
                    break;
                }

                Console.WriteLine("No products found");
                break;

            case "FindProductsByPriceRange":
                var prices = args.Split(';').Select(decimal.Parse).ToArray();
                result = shoppingBag.FindProductsByPriceRange(prices[0], prices[1]);
                if (result.Any())
                {
                    Console.WriteLine(string.Join(Environment.NewLine, result));
                    break;
                }

                Console.WriteLine("No products found");
                break;
            }
        }
    }