package pr2; public class MonthAndDay { // This assumes that no month used is part of a leap year. private static int[] DAYS_IN_MONTH = {0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; private int month; private int day; public MonthAndDay(int month, int day) { this.month = month; this.day = day; } public int getMonth() { return month; } public int getDay() { return day; } public static MonthAndDay getLater(int month, int day, int daysLater) { while (day + daysLater > DAYS_IN_MONTH[month]) { daysLater = daysLater - DAYS_IN_MONTH[month]; month++; if (month == 12) month = 1; } return new MonthAndDay(month, day+daysLater); } }