You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
598 B

  1. package de.hs_fulda.ciip.projjpn;
  2. import java.util.HashMap;
  3. public class Warehouse {
  4. protected HashMap<String, Item> pool = new HashMap<String, Item>();
  5. /**
  6. *
  7. * @param item Item to insert.
  8. * @return the inserted Item or null.
  9. */
  10. public Item insertItem(Item item) {
  11. return pool.putIfAbsent(item.getTitel(), item);
  12. }
  13. /**
  14. *
  15. * @return The total amount of all Items.
  16. */
  17. public int getCountOfStock() {
  18. int sumItems = 0;
  19. for (HashMap.Entry<String, Item> set : pool.entrySet()) {
  20. sumItems += set.getValue().getCurrentStock();
  21. }
  22. return sumItems;
  23. }
  24. }