diff --git a/src/main/java/APCalendar.java b/src/main/java/APCalendar.java index 46a3aa8..019309f 100644 --- a/src/main/java/APCalendar.java +++ b/src/main/java/APCalendar.java @@ -13,7 +13,12 @@ private static boolean isLeapYear(int year) public static int numberOfLeapYears(int year1, int year2) { /* to be implemented in part (a) */ - + int count = 0; + for(int i = year1; i <= year2; i++) + if(isLeapYear(i)) + count++; + return count; + } /** Returns the value representing the day of the week for the first day of year, @@ -52,5 +57,9 @@ private static int dayOfYear(int month, int day, int year) public static int dayOfWeek(int month, int day, int year) { /* to be implemented in part (b) */ + int pooD = firstDayOfYear(year); + int pooN = dayOfYear(month, day, year); + int result = (pooD + pooN - 1)%7; + return result; } }