/*
 * Created on Sep 7, 2005
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package edu.uprm.ece.icom5016.util;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.Iterator;

import edu.uprm.ece.icom5016.bean.ItemOrdered;
import edu.uprm.ece.icom5016.bean.ShoppingCart;

/**
 * @author elliot
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class CartInspector {
	private BigDecimal cartTotal;
	private ShoppingCart cart;
	private ItemOrdered[] items;
	
	public CartInspector(ShoppingCart cart){
		this.inspect(cart);
	}
	
	private void inspect(ShoppingCart cart){
		this.cart = cart;
		Collection c = cart.getItems();
		this.cartTotal = new BigDecimal(0.00);
		this.items = new ItemOrdered[c.size()];
		int n = 0;
		for(Iterator i = c.iterator(); i.hasNext();){
			this.items[n] = (ItemOrdered) i.next();
			this.cartTotal = this.cartTotal.add(this.items[n].getTotal());
			n++;
		}
		//System.out.println();
	}
	/**
	 * @return
	 */
	public BigDecimal getGran_total() {
		return cartTotal;
	}
	
	

	/**
	 * @return
	 */
	public ItemOrdered[] getItems() {
		return items;
	}

}
