class MonthInfo
{
// Return a string of length three
representing
// the month (with is 1-12) and
vice-versa
// Provide a reasonable return value
in case of errors.
public static String getMonth( int month )
public static int getMonth(
String month )
public static int daysInMonth( int month, int year )
private static boolean isLeapYear( int year
)
{ return ( year % 400 == 0 ) || ( year % 4 == 0 && year % 100 != 0 ); }
private static final String monthArray[ ] = { "Jan", ... };
}
public class Date
{
// PUBLIC FUNCTIONALITY
// Provide three constructors.
// One takes no parameters, the other two take
// a month, day, and year, in that order. One
of these three-parameter
// constructors takes the month as an integer,
while the other
// takes it as a string.
// Provide a setDate method that takes three
integers:
// the month, day, and year. There is no return
value.
// Provide a toString method that returns a String representation.
// Provide an equals and a compareTo method.
// Provide a dateAfter method that returns the
Date after the current Date.
// Note: the current Date is unchanged.
// Provide a futureDate method that returns the
Date in the future.
// It takes one parameter that tells how many
days in the future to look.
// If the parameter is negative treat it as
a zero.
// Note: the current Date is unchanged.
// PRIVATE INFO
// Provide three data members: the month, day,
and year, represented
// as integers. The month will range from 1-12,
the day from 1-31, and
// the year from 1 onwards.
}
Note that if the parameters used to modify a Date make no sense (for instance, Feb 31, 1999), you should print a message and use a respectable date.