/*  This main program allows the user to either characterize a data set using the class Moment,
    or too test whether the means or the variances of two data sets are the same or not (this is
    done using the class Test).  The program prompts the user which type of analysis they want to
    do, and which files to analyze.  The output is to the screen.
    
    Note in order for TestData.C to compile you need the following files in the same directory:
    
    Test.h,  ReadDataFile.h,  Moment.h,  SpecialFunction.h
    	 
*/


#include <iostream.h>
#include "ReadDataFile.h"
#include "Test.h"

float compare(Test& T) {return T.Prob();}		// This external function is used to use the
						// feature of virtual functions which is used
						// in Test.h

void main() {

  // Prompts the users input to choose what this program should do.

     cout<<"Choose one of the following options"<<endl;
     cout<<endl;
     cout<<"Look at the moment of a data set                     (a)"<<endl;
     cout<<"Test the means of two data sets(Unknown variances)   (b)"<<endl;
     cout<<"Test the means of two data sets(Same variances)      (c)"<<endl;
     cout<<"Test the means of two data sets(Different variances) (d)"<<endl;
     cout<<"Test the variances of two data sets                  (e)"<<endl;
     
     char choice;cin>>choice; 
     
     char file1[50];                                // Note maximum length of filename is 50 words.
     char file2[50];
               
     if(choice == 'a') { 

	cout<<endl;
         	cout<<"Input the filename of the input file "<<endl;   	//Inputs the filename of the data
    	cin>>file1;					//file too be looked at.
          
         	ReadDataFile F(file1);		// Here the file is read in, and arrays are created.                     

     	Moment data(F.Data(),F.DataNum());     // The usage of ReadDataFile class.		

   // Outputs all the member functions of Moment to the screen.
     	
     	cout<<endl;     
     	cout<<"Average            = "<<data.Mean()<<endl;
     	cout<<"Variance           = "<<data.Var()<<endl;
     	cout<<"Standard Deviation = "<<data.Sdev()<<endl;
     	cout<<"Average Deviation  = "<<data.Adev()<<endl;
     	cout<<"Skewness           = "<<data.Skew()<<endl;
     	cout<<"Kurtosis           = "<<data.Kurt()<<endl;

     }
     
     if(choice == 'b') {
     
	cout<<endl;
      	cout<<"Input the two filenames to be compared "<<endl; // Again inputs this time two filenames.
         	cin>>file1>>file2;

      	ReadDataFile F(file1,file2);			// Both filenames are read in.

      	Moment data1(F.Data1(),F.Data1Num());
      	Moment data2(F.Data2(),F.Data2Num());

  // Outputs to the screen.

      	cout<<endl;cout<<endl;
        	cout<<"The mean for "<<file1<<" is "<<data1.Mean()<<endl;
        	cout<<"The mean for "<<file2<<" is "<<data2.Mean()<<endl;
	cout<<endl;
        	cout<<"The probability of the means being significantly different is: ";

        	MeanTest T(F.Data1(),F.Data1Num(),F.Data2(),F.Data2Num());               
        	
         	cout<<compare(T)<<endl;	     
         			     // Here T was created as an object of type MeanTest, yet the function
        	                        // compare reads in type Test.  Hence in runtime the program decides
        	                        // which class to use.  That is using MeanTest.  This is using Prob()
        	                        // as a virtual function.
         	                        
     
     }

     if(choice == 'c') {					// The same as option 'b' but now uses
     							// SvarMeanTest.
	cout<<endl;
      	cout<<"Input the two filenames to be compared "<<endl;
      	cin>>file1>>file2;

        	ReadDataFile F(file1,file2);

         	Moment data1(F.Data1(),F.Data1Num());
        	Moment data2(F.Data2(),F.Data2Num());

        	cout<<endl;cout<<endl;
        	cout<<"The mean for "<<file1<<" is "<<data1.Mean()<<endl;
        	cout<<"The mean for "<<file2<<" is "<<data2.Mean()<<endl;
	cout<<endl;
        	cout<<"The probability of the means being significantly different is: ";

        	SvarMeanTest T(F.Data1(),F.Data1Num(),F.Data2(),F.Data2Num());

        	cout<<compare(T)<<endl;   

     }

     if(choice == 'd') {					// Same as above options 'b' and 'c'
     
	cout<<endl;
      	cout<<"Input the two filenames to be compared "<<endl;
      	cin>>file1>>file2;

	ReadDataFile F(file1,file2);

        	Moment data1(F.Data1(),F.Data1Num());
        	Moment data2(F.Data2(),F.Data2Num());

        	cout<<endl;cout<<endl;
        	cout<<"The mean for "<<file1<<" is "<<data1.Mean()<<endl;
        	cout<<"The mean for "<<file2<<" is "<<data2.Mean()<<endl;
	cout<<endl;
        	cout<<"The probability of the means being significantly different is: ";

        	DvarMeanTest T(F.Data1(),F.Data1Num(),F.Data2(),F.Data2Num());

        	cout<<compare(T)<<endl;
   
     }

     if(choice == 'e') {		// Same as options 'b' - 'd'
     
	cout<<endl;
      	cout<<"Input the two filenames to be compared "<<endl;
      	cin>>file1>>file2;

	ReadDataFile F(file1,file2);   

        	Moment data1(F.Data1(),F.Data1Num());
        	Moment data2(F.Data2(),F.Data2Num());

        	cout<<endl;cout<<endl;
        	cout<<"The variance for "<<file1<<" is "<<data1.Var()<<endl;
        	cout<<"The variance for "<<file2<<" is "<<data2.Var()<<endl;
	cout<<endl;
        	cout<<"The probability of the variances being significantly different is: ";

        	VarTest T(F.Data1(),F.Data1Num(),F.Data2(),F.Data2Num());

        	cout<<compare(T)<<endl;
   
     }   

}          
