Code example for BigDecimal

Methods: add

0
	public void addItem(String item) {
		if (!items.containsKey(item)) {
			items.put(item, new WebItem(item, new BigDecimal(Math.random(), new MathContext(2, RoundingMode.HALF_EVEN)), BigDecimal.ONE));
		} else if (items.containsKey(item)) {
			final Item old = items.get(item);
			items.put(item, new WebItem(old, BigDecimal.ONE.add(old.getQuantity())));
		} 
	} 
 
	public List<Item> getItems() {
		return new ArrayList<Item>(items.values());
	} 
 
	public void removeItem(String item) {
		if (items.containsKey(item)) {
			items.remove(item);
		}		 
	}