#include <iostream.h>
#include "UsedWords.h"

PreviouslyUsedWordList::PreviouslyUsedWordList():
	numOfElementsInList(0)
{
}

int PreviouslyUsedWordList::hasWordBeenUsed(const Word &theWord)
{

	// Checks to see if word has been used before.
	// If it hasn't it is added to the list.

	enum BOOL {False, True};
	int count, wordUsed = False;

	for (count = 0; count <= numOfElementsInList; count++)	// checks list for word.
	{
		if (theWord == UsedWords[count])
		{
			wordUsed = True;
		}
	}

	if (!wordUsed)
		addWord(theWord);

	return wordUsed;


}

void PreviouslyUsedWordList::addWord(const Word &theWord)
{
	// theWord is added to UsedWords array.
	//	numOfElementsInList is incremented.

	if (numOfElementsInList >= MaxListLength)
	{
		resetList();
	}

	UsedWords[numOfElementsInList] = theWord;
	numOfElementsInList++;

}

