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.
28 lines
598 B
28 lines
598 B
package de.hs_fulda.ciip.projjpn;
|
|
|
|
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()) {
|
|
sumItems += set.getValue().getCurrentStock();
|
|
}
|
|
return sumItems;
|
|
}
|
|
}
|