#include "solve.h"

using namespace math_tools;
using namespace std;

string read_line()
{
   string ret;
   char ch = cin.get();
   while(cin) {
      if(ch == '\n') 
         break;
      ret += ch;
      ch = cin.get(); 
   }
   return ret;
}

int
main(int argc, char ** argv)
{
   string eq,result,var;
   bool running = true;

   cout << "Please type quit to exit this program..." << endl;

   while(running) {
      cout << "eq> " << flush;

      eq = read_line();

      if(eq == "exit" || eq == "quit") {
         running = false;      
         continue;
      }

      cout << "var> " << flush;

      var = read_line();

      result = factor(eq);

      cout << "FACTOR = \"" << result << "\"" << endl;

      eq = solve(eq, var);

      cout << "ANSWER = \"" << eq << "\"" << endl;

   }

   cout << "Thank you...\n" << flush;

   return 0;
}
