package de.hs_fulda.ciip.projjpn; import java.util.HashMap; public class Warehouse { protected HashMap pool = new HashMap(); /** * * @param item Item to insert. * @return the inserted Item or null. */ public Item insertItem(Item item) { return pool.putIfAbsent(item.getTitel(), item); } /** * * @return The total amount of all Items. */ public int getCountOfStock() { int sumItems = 0; for (HashMap.Entry set : pool.entrySet()) { sumItems += set.getValue().getCurrentStock(); } return sumItems; } }