public class Date{ private int day; private int month; private final static String[] monthName = {"","January","February","March", "April","May","June","July", "August","September","October", "November","December"}; private final static int[] monthLength = {0,31,28,31,30,31,30,31,31,30, 31,30,31}; public Date(int m, int d){ day = d; month = m; } private boolean isValid(){ if (month < 1 || month > 12) return false; if (day < 1 || day > monthLength[month]) return false; return true; } public String toString(){ if (isValid()) return monthName[month]+" "+day; else return "Invalid Date"; } public Date tomorrow(){ if (isValid()){ Date tom = new Date(month,day+1); if (tom.isValid()) return tom; else{ int m; if (month==12) m = 1; else m = month + 1; return new Date(m,1); } } else return new Date(0,0); // an invalid date } }