/**
* 
* This version has been modified to handle 2 files, not just 1
* It does so in a kludgey fashion - see Remember2.java for a
* more efficient one.
*
* @author Bernstein modified by Adams
* @version 1.2 - September 9, 2008
*
*/


import java.io.*; // needed for PrintWriter
import java.util.*; // needed for Scanner


public class Remember1
{
    private static Scanner        dateScanner;
    private static PrintWriter    screen;
    private static File	          dates,dates2; // expect 2 files

    public static void main(String[] args)
    {
       GregorianCalendar        today;
       String                   name, name2; // for 2 filenames


       dates    = new File(args[0]);   // first argument from command line
		 dates2   = new File(args[1]);  // second argument from command line 
       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();       

       // dateScanner = new Scanner(System.in); //old dateScanner read from keyboard
     try 
      { 
		  dateScanner = new Scanner (dates); // dates is a new file with name from args[0]    
	   }  // end try
	   catch (FileNotFoundException fnfe)
	   {
	    System.out.println( fnfe.getMessage());	  
      }  // end catch
	    processDates(today); // processDates is a user defined mehod
    

     try 
      { 
		  dateScanner = new Scanner (dates2); // dates is a new file with name from args[1]    
	   }  // end try
		
	   catch (FileNotFoundException fnfe)
	   {
	    System.out.println( fnfe.getMessage());	  
       }  // end catch
	 
	    processDates(today); // processDates is a user defined mehod
    }// 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
      }// end processDates
    } // end class Remember1
    