/// <summary>
        /// Removes the item at the given position from the item roster.
        /// </summary>
        /// <param name="position"></param>
        public void RemoveSpecific(int position)
        {
            ItemInCart iic = listOfItems[position];

            listOfItems.RemoveAt(position);

            itemRosterTally[iic.GetName()]--;
            itemRosterTallyUsed[iic.GetName()]--;

            Consolidate(iic.GetName(), TALLY_STATE.REMOVE);
        }
Exemple #2
0
        /// <summary>
        /// Compares the item given with the parameters of this special,
        /// returns true if the item does indeed apply to the special.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool CanBeAppliedTo(ItemInCart item)
        {
            bool result = false;

            //what do we care about?
            //1. If we're affecting the same item.
            //2. If the price is lower than...what.

            if (special.Match(item.GetName()))
            {
                result = true;
            }

            return(result);
        }
        /// <summary>
        /// Adds an item into the cart of the given number (of items).
        /// </summary>
        /// <param name="itemName">The item being purchased.</param>
        /// <param name="itemNumber">How many is being purchased.</param>
        public void Add(string itemName, float itemNumber = 1)
        {
            ItemInCart newItem       = new ItemInCart(Database_API.GetItem(itemName), itemNumber);
            string     itemNameClean = newItem.GetName();

            listOfItems.Add(newItem);

            if (itemRosterTally.ContainsKey(itemNameClean))
            {
                itemRosterTally[itemNameClean]++;
                itemRosterTallyUsed[itemNameClean]++;
            }
            else
            {
                itemRosterTally.Add(itemNameClean, 1);
                itemRosterTallyUsed.Add(itemNameClean, 1);
            }

            Consolidate(itemNameClean, TALLY_STATE.ADD);
        }