package candy;

/**
 * A candy machine that provides two units of candy for every one provided
 * by a base machine.
 *
 * @author CSC223 2004F
 * @author Samuel A. Rebelsky
 * @version 1.1 of September 2006
 */
public class DoubleCandyMachine
	implements CandyMachine
{

// +--------+------------------------------------------------------------
// | Fields |
// +--------+

	/**
	 * The base candy machine from which this draws candy.
	 */
	CandyMachine base;
	
// +--------------+------------------------------------------------------
// | Constructors |
// +--------------+

	public DoubleCandyMachine(CandyMachine base)
	{
		this.base = base;
	} // DoubleCandyMachine(CandyMachine)


// +----------+----------------------------------------------------------
// | Mutators |
// +----------+

	/**
	 * Usually get twice as much candy as in previous machines.
	 */
	public String get()
		throws CandyMachineException
	{
		String tmp = base.get();
		if (base.isEmpty())
			return tmp;
		else
			return tmp + " and " + base.get();
	} // get()
	

// +-----------+---------------------------------------------------------
// | Observers |
// +-----------+

	/**
	 * Determine if the candy machine is empty.
	 */
	public boolean isEmpty()
	{
		return base.isEmpty();
	} // isEmpty()
	

} // class DoubleCandyMachine

