public class BoxOfCandy {
	
	// change the access specifier from private to package, so that
	// it is accessible in the Runner class
	Candy[][] box;
	
	public boolean moveCandyToFirstRow(int col)
	{
		boolean unChanged = true;
		
		if (box[0][col] != null) return unChanged;
		else
		{
				for (int i = 1; i< box.length; i++)
				{
					if (box[i][col] != null)
					{
						//exchange
						box[0][col]= box[i][col];
						box[i][col] = null;
						unChanged = true;
						return unChanged;
					}
					else unChanged = false;
				}
		}
		return unChanged;
	}
	
	public Candy removeNextByFlavor(String flavor)
	{
		Candy candy= null;
		for (int i=box.length-1; i>=0 ; i--)
		{
			for (int j=0; j< box[0].length; j++)
			{
				if (box[i][j] != null)
				{
					if (box[i][j].getFlavor().equalsIgnoreCase(flavor))
					{
						candy = box[i][j];
						box[i][j]= null;
						return candy;
					}
				}
			}
		}
		return candy;
	}
}
