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(); }
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); } } }