import java.io.*;
import java.util.*;
/******************************************************************************/
/** Candidate main program
 *
 *  This program does the usual open and close of files using the DABUtils methods,
 *  and then it reads the file into an ArrayList and echoes the ArrayList to the
 *  console.
 *
 *  The main difference between this program and the previous program is that the
 *  main program in this version uses a CandidateList2 class to handle all the
 *  work of the program, so the main has returned to being basically boilerplate
 *  of open files, invoke a do-the-work method, and then close up and go home.
 *
 * @author Duncan Buell
 *
 * written: 29 March 2008
*/
public class Main2
{
  public static void main(String[] args)
  {
    String inFileName = null;
    String outFileName = null;

    CandidateList2 candidateList = new CandidateList2();
    Scanner console = new Scanner(System.in);
    Scanner inDataFile = null;
    PrintWriter outDataFile = null;

    System.out.printf("Enter input file name: ");
    inFileName = console.next();

    System.out.printf("Enter output file name: ");
    outFileName = console.next();

    System.out.printf("Input file name is: %s%n",inFileName);
    System.out.printf("Output file name is: %s%n",outFileName);

    inDataFile = DABUtils.ScannerOpen(inFileName);
    System.out.printf("Input file '%s' opened, continue%n",inFileName);

    outDataFile = DABUtils.PrintWriterOpen(outFileName);
    System.out.println("Output file '" + outFileName + "' opened, continue");

/******************************************************************************/
/** Read in the candidate data
**/
    candidateList.getData(inDataFile);

    System.out.println("File input processed");

/******************************************************************************/
/** Echo the data
**/
    candidateList.echoData(outDataFile);

/******************************************************************************/
/** Close up and go home
**/
    inDataFile.close();

    outDataFile.flush();
    outDataFile.close();
    System.out.printf("File processed, terminate%n");

  } // public static void main(String[] args)

} // public class Main2

