コード例 #1
0
  @Override
  public boolean removeFromStore(Store store, int amount) {

    Integer newQuant = store.getQuantity() - amount;
    store.setQuantity(newQuant);
    return menu.getStoreDao().update(store);
  }
コード例 #2
0
 private void changeItemListInventory(String name, int quantity) {
   for (Iterator<Store> i = items.getItemList().iterator(); i.hasNext(); ) {
     Store item = (Store) i.next();
     if (item.getItem().matches(name)) {
       item.setQuantity(item.getQuantity() + quantity);
     }
   }
 }
コード例 #3
0
  @Override
  public Long sale(Long storeId, int amount) {
    Store store = menu.getStoreDao().read(storeId);
    Integer curAmount = store.getQuantity();
    Integer newAmount = curAmount - amount;
    store.setQuantity(newAmount);

    Sales nwSale = new Sales(store, new java.util.Date(), amount);
    Long id = salesDao.create(nwSale);

    return id;
  }
コード例 #4
0
 public void addOrderedItem(String name, int quantity) {
   for (Iterator<Store> i = items.getItemList().iterator(); i.hasNext(); ) {
     Store item = (Store) i.next();
     if (item.getItem().matches(name)) {
       if (item.getQuantity() >= quantity) {
         OrderItem neworderitems = new OrderItem(name, quantity, item.getItem().getCost());
         neworderitems.setTotalItemCost(quantity);
         item.setQuantity(item.getQuantity() - quantity);
         orderItemsList.add(neworderitems);
       } else {
         System.out.println(item.getQuantity() + " " + item.getItem().getName() + "are there.");
       }
     }
   }
   items.disply();
 }