
/**
  *The PuckSupply manages a pool of Pucks and provides a new
  *Puck on request. It raises the OutOfPuckException that signals losing the game
  */
public class PuckSupply{
	protected int maxPucks;
	protected int usedPucks;
	protected PlayingField fieldPtr;

	/**
	  *The constructor currently determine sthe number of Pucks available.
	  *@param field  the PlayingField in which the Pucks are used
	  */
	public PuckSupply(PlayingField field){
		maxPucks = 3;
		usedPucks = 0;
		fieldPtr = field;
	}

	/**
	  *Reports the number of Pucks remaining
	  */
	public int numberLeft(){
		return maxPucks - usedPucks;
	}

	/**
	  *Returns a new Puck if one remains
	  *pre: 
	  *post: a new Puck is returned or the OutOfPucksException has been thrown
	  */
	public Puck getPuck() throws OutOfPucksException{
		if(usedPucks < maxPucks){
			usedPucks = usedPucks + 1;
			return new Puck(fieldPtr);
		}
		else{
			throw new OutOfPucksException();
		}
	}
};
