Example #1
0
 public PromoPackage(Book book1, Book book2, int discountAmount, DiscountType discountType)
 {
     this.book1 = book1;
     this.book2 = book2;
     this.discountAmount = discountAmount;
     this.discountType = discountType;
 }
Example #2
0
        /// <summary>
        /// Gets the number of books in the inventory.
        /// </summary>
        /// <param name="book"></param>
        /// <returns></returns>
        public static int CountBooks(Book book)
        {
            if (!books.ContainsKey(book))
            {
                return 0;
            }

            return books[book];
        }
Example #3
0
        public void AddBook(int amount, Book book)
        {
            int currentAmount = 0;
            if (contents.ContainsKey(book))
            {
                currentAmount = contents[book];
            }

            currentAmount += amount;

            contents[book] = currentAmount;
        }
Example #4
0
        public static void AddBook(Book book, int amount)
        {
            if (!books.ContainsKey(book))
            {
                books.Add(book, 0);
            }

            int currentAmount = books[book];

            currentAmount += amount;

            books[book] = currentAmount;
        }
Example #5
0
        /// <summary>
        /// Deducts the amount given for the specified book in the inventory.
        /// </summary>
        /// <param name="book"></param>
        /// <param name="amount"></param>
        public static void DeductInventory(Book book, int amount)
        {
            int stock = books[book];

            if (stock - amount < 0)
            {
                throw new ArgumentException("Not enough books in stock: current stock is " + stock + ", trying to deduct " +
                    amount);
            }

            stock -= amount;

            books[book] = stock;
        }
Example #6
0
 public int GetAmount(Book book)
 {
     return contents[book];
 }
Example #7
0
 public bool ContainsBook(Book book)
 {
     return contents.ContainsKey(book);
 }