#include <iostream.h>
#include <ctype.h>
#include "GuessList.h"

PreviouslyUsedGuessList::PreviouslyUsedGuessList():
	numOfElementsInList(0)
{
	guessList[numOfElementsInList] = '\0';
}

int PreviouslyUsedGuessList::LetterBeenUsedStatus(char guess)
{
	//
	// Checks to see if 'guess' is in the list or not.
	//		
	// Returns a value of 1 (TRUE) if letter has been used.
	// Returns a value of 1 (TRUE) if letter is invalid.
	// Returns a value of 0 (FALSE) if letter has not been used
	// before..
	// 

	enum BOOL {False, True};
	int count, letterUsed = False;

	for (count = 0; count < numOfElementsInList; count++)	// checks list for guess.
	{
		if (guess == guessList[count])
		{
			letterUsed = True;
		}
	}

	// If the letter is not already in the list then add it.

	if (letterUsed == False)	
	{
		guessList[numOfElementsInList] = guess;	// adds letter to list.
		numOfElementsInList++;
		guessList[numOfElementsInList] = '\0';
	}


	return letterUsed;
}


void PreviouslyUsedGuessList::resetGuessList()
{

	// Reset numOfElementsInList so that new guess are added to start of array.
	numOfElementsInList = 0;

	// Fill first array element with '\0' to prevent previous list being displayed.

	guessList[numOfElementsInList] = '\0';
}

void PreviouslyUsedGuessList::getGuessList(char aGuestList[MaxGuessListLength])
{
	int counter;

	// copies guessList array into aGuessList array.

	for (counter = 0; counter < MaxGuessListLength; counter++)
	{
		aGuestList[counter] = guessList[counter];
	}
}