import java.io.*;
import java.util.*;
/***********************************************
 * This class prints the date and reads from files
 *
 * @author - Matt Jenkins
 * @version - V1 - January 22, 2007
 ************************************************/
 /*
 /  References and Ackknowledgements: I have recieved
 /  no help on this programming assignment
 /
 /***********************************************/
 /*Matt Jenkins
 /section 2
 /lab4
 */
public class IO_jenkinmj_Remember
{
    private static Scanner        dateScanner;
    private static PrintWriter   	screen;
    

/********************************************
 * prints the date and reads from command line
 * for a file name and reads from the file
 * 
 *********************************************/
    public static void main(String[] args)throws IOException 
    {
       GregorianCalendar        today;
       String                   name;       
		 File[] 						  dates;
		 
		 
		 dates = new File[args.length];//instantiates dates as an File array   	
       today    = new GregorianCalendar();//instantiates today as a gregorian calender
       screen   = new PrintWriter(System.out);//instantiates screen to output messages
		  
		 for (int index = 0; index < args.length; index++)//loops until args length is reached
		 {
		 	
		 	dates[index] = new File(args[index]);//creates multiple instances of the array for every argument
			dateScanner = new Scanner(dates[index]);//creates a scanner object with the command args
		 }

       screen.printf(Locale.US, "\nToday's Date: %1$te %1$tB %1$tY\n", today);// puts date in buffer
       screen.flush();//clears buffer

        

       processDates(today);//calls processDates method
    }
    

/********************************************
 * This method shows what ppl have birthdays
 * on todays date
 *
 * 
 *********************************************/
    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())//finds whos birthday is on todays date
       {
          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);//prints birthday 
             screen.flush();
          }
		 }
       
    }
    

}
