// © Copyright 1995. Joseph Bergin. All rights reserved.

#ifndef __PPBallBag__
#define __PPBallBag__

#include "Array.h"
#include "Dice.h"

// Simulates a bag of numbered balls.  Pick returns the number of one
// of the balls and removes ot from the bag.  Reset restores the bag to
// its original contents.  Roll may be used to return a number without
// removing it from the bag.  Roll returns a number of one of the balls
// still in the bag.  If you never pick, then roll behaves like a die.  

class PingPongBallBag:public Die 
{	public:
		PingPongBallBag(unsigned int howMany = 6);
		PingPongBallBag (const PingPongBallBag &d);
		~PingPongBallBag();
		PingPongBallBag & operator = (const PingPongBallBag &d);
	
		int roll();
			// Returns the value of some ball in the bag without removing
			// it from the bag.  
		int pick();
			//Returns distinct numbers between 1 and howMany until reset or
			//   until all numbers have been returned. 
			// Returns zero after all other values have been retrieved. 
			// I.E. It removes a ball from the bag and returns its value.
		void reset();
			// Restore the bag to its original state.  Put all the original	
			// balls back into it.  
	private:
		Array<int> _previous;
		int _remaining;
};

#endif
