/**
*   This file contains an alternate version of Remember.java 
*   which will handle multiple files based on the number of arguments the user enters.
*
* @author Bernstein modified by Adams
* @version 1.2 - September 10, 2008
*
*/

import java.io.*; // needed for PrintWriter
import java.util.*; // needed for Scanner

public class Remember4
{
    private static Scanner        dateScanner;
    private static PrintWriter    screen;

    public static void main(String[] args)
    {
       GregorianCalendar        today;
       File                     dates;

       today    = new GregorianCalendar();
       screen   = new PrintWriter(System.out);

       // format statement describing shape of today's date
       screen.printf(Locale.US, "\nToday's Date: %1$te %1$tB %1$tY\n", today);
       screen.flush();       

     for (int i = 0; i < args.length; i++)
       try 
       { 
		    dates = new File(args[i]);
		    dateScanner = new Scanner (dates); 
			 processDates(today); // processDates is a programmer defined mehod

	    }  // end try

	    catch (FileNotFoundException fnfe)
	    {
	      System.out.println( fnfe.getMessage());	  
       }  // end catch
	

    
    }// end main

    
    /**
	 *  This method 
	 *  @param  GregorianCalendar today
    *
	 */
	 
    private static void processDates(GregorianCalendar today)
    {
       int           day, month;              
       String        name;
       

       // Use the '\t' (tab) and '/' characters as delimiters
       dateScanner.useDelimiter("[\t/]");
          
          
       while (dateScanner.hasNext())
       {
          month = dateScanner.nextInt();
          day   = dateScanner.nextInt();
          name  = dateScanner.nextLine();

          if ((month == (today.get(Calendar.MONTH)+1)) && 
              (day   == today.get(Calendar.DAY_OF_MONTH)))
             screen.printf("%s\n", name);
          screen.flush();
       }// end while
   
	   }// processDates
    } // end class Remember4
    