// Approach 1:  Testing Shell

import java.io.*;
import SimpleInput;
import SimpleOutput;

public class Setup1 {
    
    public static void main(String[] args) throws Exception {
        
        SimpleInput in = new SimpleInput();
        SimpleOutput out = new SimpleOutput();
    
        // trap any exceptions in what follows
        try {

            // Find out if the user wants a graphical or terminal interface.
            
            out.println ("Setup1::main called");

            out.println("Please type /'term/' if you would like to use a terminal interface ");
            out.println("or /'gui/' if you would like to use a graphical interface: ");
            String iface = in.readString();
            while (iface.compareTo("gui") != 0 && iface.compareTo("term") != 0) {
                out.println("That is not a recognized command. Please try again.");
                iface = in.readString();
            }
            SchemeTesterInterface1 intface = null;
            if (iface == "gui") {
                intface = new GUI1();
            }
            else {
                intface = new Terminal1();
            }
        
            // retrieve data from interface
            String[] data = intface.getData();
            String labNumber = data[0];
            String codeLocation = data[1];
            String specialTestCases = data[2];

            out.println ("Setup1 obtained the following data from the interface:");
            out.println ("     lab number:"  + labNumber);
            out.println ("     user's program location:  " + codeLocation);
            out.println ("     special test case file:  " + specialTestCases);
            
            String authorityProgram = "/home/walker/152/project.s01/test1.ss";
            String fileNameForRegTests = "/home/walker/152/project.s01/proj-testCases1";
            out.println ("Setup1 will use:" );
            out.println ("     " + authorityProgram + " as authority program");
            out.println ("     " + fileNameForRegTests + " as file name for regular tests");
            out.println ("     level 1 as the desired correctness level");

            OutputFormatter1 of = new OutputFormatter1(intface, 1);
            out.println ("     output formatter created");
            ComparisonChecker1 cc = new ComparisonChecker1(of);
            out.println ("     comparison checker created");
            RunSchemeTest1 rstA = new RunSchemeTest1(codeLocation,5,1000,'A',cc);
            out.println ("     authority program created");
            RunSchemeTest1 rstU = new RunSchemeTest1(codeLocation,5,1000,'U',cc);
            out.println ("     user program created");
            TestGenerator1 tcg = new TestGenerator1(of, rstA, rstU);
            out.println ("     test generator created");
        
            // Now we have to
            out.println ("     Setup passing information to test case generator");
            tcg.getCases(fileNameForRegTests, specialTestCases);

        } catch (IOException e) {
            out.println ("Exception caught in Setup1");
            out.println ("   " + e.toString());
        }
    } // main
} // Setup1
