#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

#define tf(IsTrue) ((IsTrue) ? "True" : "False")

int main() {
   uCalc uc;
   // Setup a "Scientific" configuration
   uCalc scientificCalc;
   scientificCalc.DefineFunction("sqrt(x) = x^0.5");
   scientificCalc.DefineVariable("pi = 3.14159");

   // Setup a "Financial" configuration
   uCalc financialCalc;
   financialCalc.DefineFunction("tax(amount, rate) = amount * (rate/100)");

   // Set the scientific calculator as the default
   scientificCalc.IsDefault(true);
   cout << "Current default is scientific? " << tf(scientificCalc.IsDefault()) << endl;

   // Components that rely on the default instance now use the scientific setup.
   uCalc::Expression expr1 = "2 * pi";
   cout << "2 * pi = " << expr1.Evaluate() << endl;

   // Now, switch the default to the financial calculator
   financialCalc.IsDefault(true);
   cout << "Current default is scientific? " << tf(scientificCalc.IsDefault()) << endl; // Should be false now
   cout << "Current default is financial? " << tf(financialCalc.IsDefault()) << endl;

   // New components will use the financial setup.
   uCalc::Expression expr2 = "tax(50000, 20)";
   cout << "Tax on 50000 at 20% = " << expr2.Evaluate() << endl;
}