#include <iostream.h>
#include "RndWordGenerator.h"


Word RandomWordGenerator::chooseSecretWord(WordList &aWordList)
{
	int numWordsInWordList;
	int randomWordNumber;
	Word tempWord;


	// Get the number of words currently in the word list.
	
	numWordsInWordList = aWordList.getNumOfElementsInList();

	// Generate a random number between 1 and the number of words in word list.
	// 0 is used for the category title in the word list.

	do
	{

		randomWordNumber = theRandNumGenerator.generateNum(1,numWordsInWordList);

		// Get word at list array element [randomWordNumber]

		tempWord = aWordList.getWord(randomWordNumber);

	}while(theUsedWordList.hasWordBeenUsed(tempWord));	// check to see if word has already been used.

	return tempWord;	// return the chosen word.
}

void RandomWordGenerator::resetGenerator()
{
	theUsedWordList.resetList();
}
