/** The java.util.Date class is restricted to dates after 1970 and seems to have other bugs. This is my replacement for it. Note years should be held with the first two digits and months range from 1 to 12. This is different from java.util.Date. Written by Kim Bruce on 1/25/97. */ public class Date{ protected int year; /** current year */ protected int month; /** current month */ protected int day; /** current day */ public Date() /** post: Constructs today's date. */ { java.util.Date today = new java.util.Date(); // Get date from java utility. year = today.getYear()+1900; month = today.getMonth()+1; day = today.getDay(); } // Another constructor for Date which takes parameters for the date. public Date(int ayear, int amonth, int aday) /** post: Constructs date given by parameters. */ { year = ayear; month = amonth; day = aday; } public int getYear() /** post: Returns the year. */ { return year; } public int getMonth() /** post: Returns the month. */ { return month; } public int getDay() /** post: Returns the day. */ { return day; } public void setYear(int newYear) /** post: year set to newYear. */ { year = newYear; } public void setMonth(int newMonth) /** post: month set to newMonth. */ { month = newMonth; } public void setDay(int newDay) /** post: day set to newDay. */ { day = newDay; } /* method which returns a printable version of date. This makes it easier to output the date. If simply use an expression of type Date in an output statement, the toString method will automagically be called to convert it to a string. */ public String toString() /** Returns printable version of Date. */ { String strmonth; switch (month){ case 1: strmonth = "January "; break; case 2: strmonth = "February "; break; case 3: strmonth = "March "; break; case 4: strmonth = "April "; break; case 5: strmonth = "May "; break; case 6: strmonth = "June "; break; case 7: strmonth = "July "; break; case 8: strmonth = "August "; break; case 9: strmonth = "September "; break; case 10: strmonth = "October "; break; case 11: strmonth = "November "; break; case 12: strmonth = "December "; break; default: strmonth = "Error "; } return strmonth + day +", "+year; } }