import java.io.*;
import java.util.*;

/**************************************
 * Remember.java 
 *
 * @author Chris MacDonald
 * @version 1 
 **************************************/
// Date:  January 22, 2007
// Section 1
// Lab 2

public class IO_macdoncj_Remember
{
    private static Scanner        dateScanner;
    private static PrintWriter    screen;
    
	 /********************************************
	 * main - controls action of the application.
	 *		    All output will be done here.
	 *
	 * @param String[] args
	 *********************************************/
	 public static void main(String[] args)
    {
	 	 File							  dates;
       GregorianCalendar        today;
       String                   name;       

		 dates	 = new File(args[0]);
       today    = new GregorianCalendar();
       screen   = new PrintWriter(System.out);
		 
		 // Iterate for multiple files
		 for(int i = 0; i < args.length; i++)
		 {
		 	dates = new File(args[i]);
		 
			screen.printf(Locale.US, "\nToday's Date: %1$te %1$tB %1$tY\n", today);
       	screen.flush();       
		 
		 	try
		 	{
      	  dateScanner = new Scanner(dates);
		 	}
		
		   catch(FileNotFoundException fnfe)
		 	{
		 	  System.out.println("File " + args[0] + " not found -- exiting.");
			  System.exit(0);
		   }	

         processDates(today);
		 }
	 }
    

	 /********************************************
	 * processDates - read in the data from a file
	 *						and process information
	 *
	 * @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/]");
          
       // Scan file for data until EOF   
       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();
          }
       }
    }
}
