import java.io.*;
import java.util.*;
/**************************
*This program takes today's date and
*sees if it matches one of the birthdays
*that are given
*
*@author - Bryan Wiseman
*@version - 1
*****************************/
//Date 1/22/2007
//Lab 04
//Section 1

public class IO_wisemabd_Remember
{
    private static Scanner        dateScanner; //this is a scanner option
    private static PrintWriter    screen;		  //this is a object that 
    

	 /******************************
	 *This method scans for the date
	 *that is given by the user
	 *****************************/
    public static void main(String[] args)
    {
       GregorianCalendar        today;	//this holds the date that is given
       String                   name;  
		 File							  dates; //holds the files
		 int							  limit; //holds the number of command lines

       limit    = args.length;
       today    = new GregorianCalendar();
       screen   = new PrintWriter(System.out);
		 //goes through each command line
		 for(int num = 0; num < limit; num++)
		 {
		 	dates	 = new File(args[num]);
			//gets the date
       	screen.printf(Locale.US, "\nToday's Date: %1$te %1$tB %1$tY\n", today);
      	 screen.flush();       
		 //catches the program if cannot find the file
		 	try
		 	{	
    	 	  dateScanner = new Scanner(dates);
		 	}
		 	catch(FileNotFoundException fnfe)
		 	{
		 		screen.println("File Not Found");
				screen.flush();
				System.exit(0);
		 	}

       	processDates(today);
		 }
	 }
    
	 /****************************
	 *This method compares the date
	 *give to the dates in the file
	 *prints name of the person
	 *@param - GregorianCalender today
	 ***************************/

    private static void processDates(GregorianCalendar today)
    {
       int           day, month;  //hold the date values            
       String        name;			 //holds the name that corresponds to the date
       

       // Use the '\t' (tab) and '/' characters as delimiters
       dateScanner.useDelimiter("[\t/]");
          
       //take the date and compares it   
       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();
          }
       }
    }
    

}
