// This program uses the Date interface and the DateImpl class.
// Barry Cornelius, 19 June 2000
import java.io. BufferedReader;
import java.io. InputStreamReader;
import java.io. IOException;
public class NoelProg
{
   public static void main(final String[] pArgs) throws IOException
   {
      // use the constructor that has three parameters of type int
      final Date tNoelDate = new DateImpl(2000, 12, 25);
      System.out.println("tNoelDate is: " + tNoelDate);
      // read a String and use the constructor that has a String parameter
      final BufferedReader tKeyboard =
                    new BufferedReader(new InputStreamReader(System.in));
      System.out.print("Type in the date, e.g., 2000-12-25: ");
      System.out.flush();
      final String tOtherDateString = tKeyboard.readLine();
      final Date tOtherDate = new DateImpl(tOtherDateString);
      System.out.println("tOtherDate is: " + tOtherDate);
      // compare tNoelDate and tOtherDate using == and Date's equals method
      System.out.println("tUsingOperator: " + (tNoelDate==tOtherDate));
      System.out.println("tNoelDate.equals: " +
                                         tNoelDate.equals(tOtherDate));
      System.out.println("tOtherDate.equals: " +
                                         tOtherDate.equals(tNoelDate));
      // use the constructor that has a parameter of type Date
      final Date tHappyDate = new DateImpl(tNoelDate);
      System.out.println("tHappyDate is: " + tHappyDate);
      // compare tNoelDate and tHappyDate using == and Date's equals method
      System.out.println("tUsingOperator: " + (tNoelDate==tHappyDate));
      System.out.println("tNoelDate.equals: " +
                                         tNoelDate.equals(tHappyDate));
      System.out.println("tHappyDate.equals: " +
                                         tHappyDate.equals(tNoelDate));
      // use the isLeap function on the three Date variables
      System.out.println("tNoelDate.iIsLeap: " + iIsLeap(tNoelDate));
      System.out.println("tOtherDate.iIsLeap: " + iIsLeap(tOtherDate));
      System.out.println("tHappyDate.iIsLeap: " + iIsLeap(tHappyDate));
   }
   private static boolean iIsLeap(final Date pDate)
   {
      final int tYear = pDate.getYear();
      return (tYear%400==0) || (tYear%4==0 && tYear%100!=0);
   }
}
