   import java.io.*;
   import java.util.*;

/**************************************
 * David Wayne Moore II
 * 1/22/07
 * Section 1
 * Lab 4
 **************************************/
 
// clas name
    public class IO_mooredw_Remember
   {
   
   /******************************************
   */
   // Scanner and PrintWriter objects declared as private and static 
      private static Scanner        dateScanner; // Declaration of dateScanner as a Scanner object
      private static PrintWriter    screen; // Declaration of screen as a PrintWriter object
    
   // method header for main method
       public static void main(String[] args)
      {
         GregorianCalendar        today; // Declaration of today as a GregorianCalendar object
         String                   name; // Declarattion of name as a String object
         File							 dates; // Declaration of date as a File object
       
         today    = new GregorianCalendar(); // Instantiation of variable today
         screen   = new PrintWriter(System.out); // Instantiation of screen object
       
         for (int x = 0; x < args.length; x++) // for loop so that the program will process multiple files
         {
            dates = new File(args[x]); // Instantiation of date object
         
         // Print out of the date in the United States
            screen.printf(Locale.US, "\nToday's Date: %1$te %1$tB %1$tY\n", today);
            screen.flush(); // Flushes the output stream    
         
         
         // try catch block so for the FileNotFoundException
            try
            {
               dateScanner = new Scanner(dates); // Instantiation of dateScanner object
            }
                catch (FileNotFoundException fnfe)
               {
                  System.out.println("This file was not found"); // message outputed if exception is thrown
               }
         
         // Calls on the method processDates by passin in the variable today
            processDates(today);
         }
      }
   
   /**********************************************
    * This method takes in todays date
	 *
	 * @param today passed as object of GregorianCalendar
    **********************************************/
     
       private static void processDates(GregorianCalendar today)
      {
         int           day, month; // variables that are integer attributes            
         String        name; // name of persons birthday       
      
       // Use the '\t' (tab) and '/' characters as delimiters
         dateScanner.useDelimiter("[\t/]");
          
       // while loop that loops until all methods are ran
         while (dateScanner.hasNext())
         {
            month = dateScanner.nextInt(); // stores the month number in variable month
            day   = dateScanner.nextInt(); // stores the day number in variable day
            name  = dateScanner.nextLine(); // stores the name of persons birthday in variable name
         
			// if statement that connects birthday to person's name
            if ((month == (today.get(Calendar.MONTH)+1)) && 
              (day   == today.get(Calendar.DAY_OF_MONTH)))
            {
               screen.printf("%s\n", name); // Output of birthday person's name
               screen.flush(); // flushes anything still left in the buffer
            }
         }
      }
    
   
   }
