コード例 #1
0
ファイル: Receipt.cs プロジェクト: taylorg18/WaitStaffApp1
        /**
        * add an item to the reciept and its price to the bill
        *
        * newItem the food item to add
        */
        public void addItem(FoodItem newItem)
        {
            if(iNumItems >= itemsBought.Length)
            {
                return;
            }
            fBill += newItem.getPrice();
            itemsBought[iNumItems] = new FoodItem(newItem.getName(), newItem.getPrice(), newItem.getTime());
            itemsBought[iNumItems].setAmountSold(1);
            iNumItems++;

            this.updateTotalItemBought(newItem);
        }
コード例 #2
0
ファイル: FoodMenu.cs プロジェクト: taylorg18/WaitStaffApp1
 public void undoBuy(FoodItem item, int undo)
 {
     for(int i = 0; i < items.Length; i++)
     {
        if (items[i].getName().Equals(item.getName()))
         {
             items[i].undoSold(undo);
          }
     }
 }
コード例 #3
0
ファイル: Receipt.cs プロジェクト: taylorg18/WaitStaffApp1
        /**
        * searches and removes one instance of a food item with the name of the given item
        *
        * returns 0 if successful
        * returns 1 in nothing removed
        */
        public int removeItem(FoodItem item)
        {
            fBill -= item.getPrice();

            for(int i = 0; i < itemsBought.Length; i++)
            {
                if(itemsBought[i] != null && itemsBought[i].getName().Equals(item.getName()))
                {
                    itemsBought[i] = null;

                    return 0;
                }

            }
            return 1;
        }
コード例 #4
0
ファイル: Receipt.cs プロジェクト: taylorg18/WaitStaffApp1
        /**
        * searches and updates one common item to have a total count of the number sold
        *
        * returns 0 if successful
        * returns 1 in nothing removed
        */
        public void updateTotalItemBought(FoodItem item)
        {
            for (int i = 0; i < itemsBought.Length; i++)
            {
                if (itemsBought[i] != null && itemsBought[i].getName().Equals(item.getName()))
                {
                    itemsBought[i].setAmountSold(itemsBought[i].getSold() + 1);
                    return;
               }

            }
        }
コード例 #5
0
ファイル: Receipt.cs プロジェクト: taylorg18/WaitStaffApp1
        /**
         * searches and removes one instance of a food item with the name of the given item
         *
         * returns 0 if successful
         * returns 1 in nothing removed
         */
        public int removeAllItem(FoodItem item)
        {
            fBill -= item.getPrice();

            int i = 0;
            ArrayList temp = new ArrayList();

            foreach (FoodItem list in itemsBought)
            {
                if (list != null && list.getName().Equals(item.getName()))
                {
                    list.setAmountSold(0);
                }

            }

            return 1;
        }