package candy;

import java.lang.reflect.Constructor;

/**
 * A candy machine that has the capacity of N basic candy machines.
 * by a base machine.
 *
 * @author Samuel A. Rebelsky
 * @author CSC223 2004F
 * @version 1.1 of September 2006
 */
public class BiggerCandyMachine
	implements CandyMachine
{

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

	int machinesLeft = 5;
	CandyMachine base;
    CandyMachineFactory fac;

// +--------------+------------------------------------------------------
// | Constructors |
// +--------------+

	public BiggerCandyMachine(CandyMachineFactory fac) {
        this.fac = fac;
		this.base = this.fac.makeNew();
	} // BiggerCandyMachine(CandyMachine)

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

	public String get()
		throws CandyMachineException
	{
		// Build a new machine, if necessary
		if (this.base.isEmpty() && this.machinesLeft > 0) {
			this.base = this.newMachine(); 
		}
		return base.get();
	} // get()

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

	public boolean isEmpty()
	{
		// For the bigger machine to be empty, we need
		// no other machines left and the base machine to
		// be empty.
		return (this.machinesLeft == 0) && this.base.isEmpty();
	} // isEmpty()

// +-------+-------------------------------------------------------------
// | Local |
// +-------+

	private CandyMachine newMachine()
		throws CandyMachineException
	{
        // STUB
		return null; 
	} // newMachine()

} // class BiggerCandyMachine

