import java.text.NumberFormat;
/*****************************************************************
 * Item.java
 *
 * Represents an item in a shopping cart.
 ***************************************************************/
public class Item
{
   /** Name or description of the shopping cart item. **/
	private Produce 	thing;
   /** Number of this item in the shopping cart. **/
   private int    	quantity;

   /**********************************************************
    * Create a new item with the given attributes.
    * @param thing The produce type for this item
    * @param numPurchased The total number of the item purchased 
    **********************************************************/
   public Item (Produce thing, int numPurchased)
   {  
             // make me
				 this.thing = thing;
				 this.quantity = numPurchased;
   }

   /*********************************************************
    * The description of the item in string format
    * @return The String representation of the item
    ********************************************************/
   public String toString ()
   {
		String builder;
		NumberFormat fmt;
		
		fmt = NumberFormat.getCurrencyInstance();

		builder = String.format("%-30s%10d%10s", thing.toString(), quantity, fmt.format(getItemCost()));
		return builder;

   }
   /******************************************************
    * Returns the unit price of the item.  Hint: Use Produce
    * @return Price of one item
    ******************************************************/
   public double getPrice()
   {
      // make me  		      return -1;
		return thing.getUnitPrice();
   }
   /******************************************************
    * Returns the description of the item.  Hint: Use Produce
    * @return The name or description of the item
    ******************************************************/
   public String getName()
   {
      // make me       return "What is my name?";
		return thing.toString();
   }
   /******************************************************
    * Returns the quantity of the item
    * @return Quantity of one item
    ******************************************************/
   public int getQuantity()
   {
      // make me       return -1;
		return this.quantity;
   }
    /******************************************************
    * Returns the total cost of this item (uses the quantity and 
	 * the produce unit cost). 
    * @return Cost of this of this item
    ******************************************************/
   public double getItemCost()
   {
//	   System.out.println (" 1 quantity is " + this.quantity + " and unit price is " + getPrice());
      //  return -1;
//		System.out.println(" 2 quantity is " + this.quantity + " and unit price is " + thing.getUnitPrice());
//      return this.quantity * thing.getUnitPrice();
		return this.quantity * getPrice();
   }

}