#include "letters.h"

Letters::Letters(const string& s)
// post: object represents s as a "word to be guessed"
//       myDisplay is all blanks
{
    myString = s;
    myDisplay = "";
    int k;
    for(k=0; k < s.length(); k++)
    {
	myDisplay += "_";
    }
    
}

bool Letters::GuessLetter(const string& letter)
// post: returns true if letter in myString (word to be guessed)
//       also changes myDisplay to record letter appropriately
//       if letter is in myString    
{
    int pos = myString.find(letter);
    if (pos == string::npos)
    {
	return false;
    }

    // you should add code here to alter
    // myDisplay appropriately

    return true;
}

void Letters::Display()
// post: displays word-to-be-guessed using __ or real letters
//       depending on whether a letter has been guessed
//       use __ for letters not guessed
//       This function just prints myDisplay formatted nicely    
{
    int k;
    for(k=0; k < myDisplay.length(); k++)
    {
	cout << " " << myDisplay.substr(k,1) << " ";
    }
    cout << endl << endl;
}

