Class MyDate

java.lang.Object
  |
  +--MyDate

public class MyDate
extends java.lang.Object

Provide services to maintain date objects.


Constructor Summary
MyDate()
          Create a default date initialized to 1/1/1980
MyDate(int d, int m, int y)
          Create a date initialized to the given parameters.
 
Method Summary
 boolean equals(MyDate other)
          Determines if the given date is the same as this date.
 int getDay()
          Determine the day of this date.
 int getMonth()
          Determine the month of this date.
 int getYear()
          Determine the year of this date.
 boolean setDMY(int d, int m, int y)
          Change this date to the given one.
 java.lang.String toString()
          Return a string representation of this date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MyDate

public MyDate(int d,
              int m,
              int y)
Create a date initialized to the given parameters. If the given date does not exist, the program terminates.
Parameters:
d - the day of the month (1-31)
m - the month number (1-12)
y - the year

MyDate

public MyDate()
Create a default date initialized to 1/1/1980
Method Detail

getDay

public int getDay()
Determine the day of this date.
Returns:
the day number of this date.

getMonth

public int getMonth()
Determine the month of this date.
Returns:
the month number of this date.

getYear

public int getYear()
Determine the year of this date.
Returns:
the year of this date.

setDMY

public boolean setDMY(int d,
                      int m,
                      int y)
Change this date to the given one. If the given one is invalid, no change is made.
Parameters:
d - the day of the month (1-31)
m - the month number (1-12)
y - the year
Returns:
true if the date was changed as requested and return false otherwise. The date will not be changed if the given d,m,y do not represent a valid date.

equals

public boolean equals(MyDate other)
Determines if the given date is the same as this date.
Parameters:
other - the given date.
Returns:
true if the given date is the same as this date. false otherwise.

toString

public java.lang.String toString()
Return a string representation of this date.
Overrides:
toString in class java.lang.Object
Returns:
the string "mmm. d, y", where mmm is the 3-letter month name (e.g. Jan), d is the day number, and y is the year.