package Chapter1.Section2;

import edu.princeton.cs.algs4.*;

public class Exercise11
{
    private static int[] daysInMonths = new int[]
	{-1,
	31,
	28,
	31,
	30,
	31,
	30,
	31,
	31,
	30,
	31,
	30,
	31};

    public static void main (String[] args)
    {
	testGoodDatesNonLeapYear();
	testZeroMonth();
	testOutMonth();
	testZeroDay();
	testOutDay();
    }

    public static void testGoodDatesNonLeapYear()
    {
	StdOut.println("testGoodDatesNonLeapYear()");

	int year = 2017;
	for (int month = 1; month < daysInMonths.length; month++)
	{
	    for (int day = 1; day <= daysInMonths[month]; day++)
	    {
		SmartDate date = new SmartDate(month, day, year);
	    }
	}

	pGood();
    }

    public static void pGood()
    {
	StdOut.println("\tGood!");
    }

    public static void testZeroMonth()
    {
	StdOut.println("testZeroMonth()");
	try
	{
	    SmartDate date = new SmartDate(0, 1, 2017);
	    throw new RuntimeException();
	}
	catch (IllegalArgumentException ex)
	{
	    pGood();
	}
    }

    public static void testOutMonth()
    {
	StdOut.println("testOutMonth()");
	try
	{
	    SmartDate date = new SmartDate(daysInMonths.length, 1, 2017);
	    throw new RuntimeException();
	}
	catch (IllegalArgumentException ex)
	{
	    pGood();
	}
    }

    public static void testZeroDay()
    {
	StdOut.println("testZeroDay()");
	
	for (int month = 1; month < daysInMonths.length; month++)
	{
	    try
	    {
		SmartDate date = new SmartDate(month, 0, 2017);
		throw new RuntimeException();
	    }
	    catch (IllegalArgumentException ex) { }
	}

	pGood();
    }

    public static void testOutDay()
    {
	StdOut.println("testOutDay()");

	for (int month = 1; month < daysInMonths.length; month++)
	{
	    try
	    {
		SmartDate date = new SmartDate(month, daysInMonths[month] + 1, 2017);
		throw new RuntimeException();
	    }
	    catch (IllegalArgumentException ex) { }
	}

	pGood();
    }
}

@@ -274,24 +274,25 @@
 LeapYear();%0A
+%0A
 %09testZeroMon
@@ -344,16 +344,92 @@
 utDay();
+%0A%0A%09testGoodLeapYear();%0A%09testHundrethLeapYear();%0A%09testFourHundrethLeapYear();
 %0A    %7D%0A%0A
@@ -1943,32 +1943,604 @@
 ion ex) %7B %7D%0A%09%7D%0A%0A
+%09pGood();%0A    %7D%0A%0A    public static void testGoodLeapYear()%0A    %7B%0A%09StdOut.println(%22testGoodLeapYear()%22);%0A%0A%09SmartDate date = new SmartDate(2, 29, 2012);%0A%0A%09pGood();%0A    %7D%0A%0A    public static void testHundrethLeapYear()%0A    %7B%0A%09StdOut.println(%22testHundrethLeapYear()%22);%0A%0A%09try%0A%09%7B%0A%09    SmartDate date = new SmartDate(2, 29, 2100);%0A%09    throw new RuntimeException();%0A%09%7D%0A%09catch (IllegalArgumentException ex) %7B %7D%0A%0A%0A%09pGood();%0A    %7D%0A%0A    public static void testFourHundrethLeapYear()%0A    %7B%0A%09StdOut.println(%22testFourHundrethLeapYear()%22);%0A%0A%09SmartDate date = new SmartDate(2, 29, 2400);%0A%0A
 %09pGood();%0A    %7D%0A

Add leap year tests