Hey
I'm in an AP Computer Science class working on classes. We have been working on a project that is a date class that does certain things like setYear, getMonth, getDay, etc. I have gotten all of those to work, except for one. The last one is a boolean method to test if the old date is equal to the new date.
It is public boolean equals(Date otherDate)
I can't get anything to work. Below is my class code:
public class Date
{
private int mnth;
private int dy;
private int yr;
public Date()
{
mnth = 1;
dy = 1;
yr = 1;
}
public Date(int month, int day, int year)
{
mnth = month;
dy = day;
yr = year;
}
/**
* Accessors
*/
/**
* Modifiers
*/
public int getMonth()
{
return mnth;
}
public int getYear()
{
return yr;
}
public int getDay()
{
return dy;
}
public String getMonthName()
{
String str = new String();
if (mnth==1)
return("January");
if (mnth==2)
return("February");
if (mnth==3)
return("March");
if (mnth==4)
return("April");
if (mnth==5)
return("May");
if (mnth==6)
return("June");
if (mnth==7)
return("July");
if (mnth==8)
return("August");
if (mnth==9)
return("September");
if (mnth==10)
return("October");
if (mnth==11)
return("November");
if (mnth==12)
return("December");
return "You input an incorrect month.";
}
public void setYear(int newYear)
{
yr = newYear;
}
public void setEqual(int newMonth, int newDay, int newYear)
{
mnth = newMonth;
dy = newDay;
yr = newYear;
}
public boolean equals(Date otherDate)
{
}
}
Hope you can help me out
Thanks!