#include <iostream>

#include <fstream>

#include <cstdlib>

#include <ctime>

 

#include "fraction.h"

 

using namespace std;

 

int main()

{

   ofstream ftest1("test1.txt");

   ofstream ftest2("test2.txt");

 

   if (!ftest1 || !ftest2) {

      cout << "cannot create file" << endl;

      return 1;

   }

 

   srand(static_cast<unsigned>(time(0)));

 

   for (int k = 0; k < 1000; ++k) {

      Rational r1((rand() % 2 ? -1 : 1) * (rand() % 100), rand() % 100 + 1);

      Rational r2((rand() % 2 ? -1 : 1) *(rand() % 100 + 1), rand() % 100 + 1);

      ftest1 << r1 << " + " << r2 << " = " << r1 + r2 << endl;

      ftest1 << r1 << " - " << r2 << " = " << r1 - r2 << endl;

      ftest1 << r1 << " * " << r2 << " = " << r1 * r2 << endl;

      ftest1 << r1 << " / " << r2 << " = " << r1 / r2 << endl;

      ftest1 << "***********************************************************" << endl;

   }

  

   for (int k = 0; k < 1000; ++k) {

      Rational r1((rand() % 2 ? -1 : 1) * (rand() % 100), rand() % 100 + 1);

      Rational r2((rand() % 2 ? -1 : 1) *(rand() % 100 + 1), rand() % 100 + 1);

      if (r1 > r2)

         ftest2 << r1 << " > " << r2 << endl;

      else if (r1 < r2)

         ftest2 << r1 << " < " << r2 << endl;

      else

         ftest2 << r1 << " == " << r2 << endl;

      ftest2 << "***********************************************************" << endl;

   }

 

   return 0;

}