|
|
@ -5,10 +5,19 @@ import java.util.HashMap; |
|
|
|
public class Warehouse { |
|
|
|
protected HashMap<String, Item> pool = new HashMap<String, Item>(); |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @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<String, Item> set : pool.entrySet()) { |
|
|
|