#include "CS35lib.h"

void encode_it (char word[], char coded[])
{
	char letter;
	int counter;
	
	for (counter=0; counter <strlen(word) ;counter++ )
	{
		cout<<"Change letter "<<word[counter]<<" to: ";
		cin>>letter;
		coded[counter]=letter;
	}
	cout<<"This is the new word encoded "<<coded<<endl;
}	
void try_to_guess(char guess[], char word[])
{
	int counter = 0;
	
	
	int i,d=0,c=0;
//	 cin>>guess;
	while (counter < 5)
		{
	for (i=0; i<strlen(word); i++)
	{
		
	    for(d=0; d < strlen(word); d++)
      		 {
			
	        if (guess[i] == word[d])
		   {
	           	c++;
		   }
		}
       	}
       	
	
	if ( c == strlen(word))
		{
			counter = 5;
			cout<<endl;
			cout<<setw(20)<<"YOU GOT IT !! \n";
			return;
		}
//	else 
//	{
//		
//	   cout<<"You have "<<c<<" correct letters from origional word ,try again: ";
//	   cin>>guess;
//		
//	}
//	}
	
}


int main()
{
	int i=0;
	char word[8], new_word[8], guess[8];
	char letter;
	cout<<"Player 1: \n";
	cout<<"Enter a 5 letter word (No letter repetition): ";
	getline(word);
    encode_it (word, new_word);
	cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
	cout<<"This is the new encoded word: "<<new_word<<endl;
	cout<<"Player 2: \n";
	cout<<"Try to guess the origional word (No letter repetition) : ";
//	cin>>guess;
	try_to_guess (guess, word);
	

	
	return 0;
}
