Ejemplo n.º 1
0
        /// <summary>
        /// Main Method.
        /// </summary>
        public static void Main()
        {
            // Add CountryVatTax countries - id, vat, isDefault
            CountryVatTax bg = new CountryVatTax(1, 20, true);

            // Add countries to list
            List<CountryVatTax> countriesList = new List<CountryVatTax>() { bg };

            // Initialise VatTaxCalculator with the countries list
            VatTaxCalculator calc = new VatTaxCalculator(countriesList);

            // Add products - id, name, quantity, price, country
            Product prod1 = new Product(0, "prod", 5, 10, bg);

            // Add products to list
            List<Product> productsList = new List<Product>() { prod1 };

            // Initialise a new Inventory with the products list
            ShopInventory newInventory = new ShopInventory(productsList);

            // Add product id and quantity to orderdict
            Dictionary<int, int> orderdict = new Dictionary<int, int> { { 0, 2 } };

            Order newOrder = new Order(orderdict);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ShopInventory"/> class with a single product.
 /// </summary>
 /// <param name="productToAdd">Adds a product.</param>
 public ShopInventory(Product productToAdd)
 {
     // Checks if product exists, if so, increments its quantity by 1, else adds as new item
     if (!this.productsList.Keys.Contains(productToAdd))
     {
         this.productsList.Add(productToAdd, 1);
     }
     else
     {
         this.productsList[productToAdd]++;
     }
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            CountryVatTax obj = new CountryVatTax(1, 20, false);
            CountryVatTax obj1 = new CountryVatTax(2, 10, true);
            List<CountryVatTax> countries = new List<CountryVatTax>() { obj, obj1 };
            Calculator calcObj = new Calculator(countries);
            calcObj.Calc(5);
            calcObj.Calc(5, 1);

            Product product = new Product(5, 1, "Хак", 5, 1, countries);
            Product product2 = new Product(10, 1, "България", 5, 2, countries);
            ShopInventory newShopInvertory = new ShopInventory(product);
            Console.WriteLine("If all products of that type are sold out, the profil you will gain is = {0}", newShopInvertory.Audit());

            Order firstOrder = new Order(1, 3);
            newShopInvertory.RequestOrder(firstOrder);
        }