public PromoPackage(Book book1, Book book2, int discountAmount, DiscountType discountType)
 {
     this.book1 = book1;
     this.book2 = book2;
     this.discountAmount = discountAmount;
     this.discountType = discountType;
 }
Exemple #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];
        }
Exemple #3
0
        public void AddBook(int amount, Book book)
        {
            int currentAmount = 0;
            if (contents.ContainsKey(book))
            {
                currentAmount = contents[book];
            }

            currentAmount += amount;

            contents[book] = currentAmount;
        }
Exemple #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;
        }
Exemple #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;
        }
Exemple #6
0
 public int GetAmount(Book book)
 {
     return contents[book];
 }
Exemple #7
0
 public bool ContainsBook(Book book)
 {
     return contents.ContainsKey(book);
 }