/*----
  signature: main: void -> int
  purpose: to allow the user to guess a word
      of the day, and keep letting them guess
      until they get it or want to quit

  compile using (typed all on one line)
      g++ guess_word.cpp guess_match.cpp letter_match.cpp
          letter_elsewhere.cpp -o guess_word
  run using:
      ./guess_word

  by: Sharon Tuttle
  last modified: 2022-09-06
----*/

#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include "guess_match.h"   
using namespace std;

int main()
{
    cout << boolalpha;

    /*---
    some pseudocode for my approach:

    get a first guess
    while the guess is wrong or not empty
        show the guess_match result
	get a next guess

    give a closing message
    ---*/

    const string EX_WORD_OF_DAY = "aiden";

    // get a first guess

    string guess;
    cout << "Enter a guess, or type enter to quit: ";

    getline(cin, guess);

    // while the guess is wrong or not empty
    //     show the guess_match result
    //     get a next guess

    while ((guess != EX_WORD_OF_DAY)
           && (guess != ""))
    {
        cout << "No, but here is a hint: "
	     << guess_match(EX_WORD_OF_DAY, guess)
	     << endl;

        cout << "\nEnter another guess, or type "
	     << " enter to quit: " << endl;
	getline(cin, guess);
    }

    // give a closing message
    
    if (guess == EX_WORD_OF_DAY)
    {
        cout << "Congratulations! You got it!"
	     << endl;
    }
    else
    {
        cout << "OK, bye!" << endl;
    }

    return EXIT_SUCCESS;
}