Ok so I am messing around with a program and have no idea how to go about doing this but here is the code for the class date....
From what I've been told the class Date was designed and implemented to keep track of a date, but it has very limited operations. I have to redefine the class Date so that, in addition to the operations already defined, it can perform the following operations on a date:
-Set the Month
-Set the Day
-Set the Year
-Return the Month
-Return the Day
-Return the Year
-Test whether the year is a leap year
-Return the number of days in the month. For example, if the date is 3-12-2005, the number of days to be returned is 31 because there are 31 days in March.
-Return the number of days passed in the year. For example if the date is 3-18-2005, the number of days passed in the year is 77. Note that the number of days returned also includes the current day.
-Return the number of days remaining in the year. For example, if the date is 3-18-2005, the number of days remaining in the year is 288.
-Calculate the new date by adding a fixed number of days to the date. For example, if the date is 3-18-2005 and the days to be added are 25, the new date is 4-12-2005.
-Return a reference to the object containing a copy of the date.
-Make a copy of another date. Given a reference to an object containing a date, copy the data members of the object into the corresponding data members of this object.
-Write the definitions of the methods to implement the operations defined for the class Date.
Please if anyone can help that would be amazing!?!
Code:
public class Date
{
private int dMonth;
private int dDay;
private in dYear;
public Date()
{
dMonth = 1;
dDay = 1 ;
dYear = 1900;
}
public Date(int month, int day, int year)
{
dMonth = month;
dDay = day;
dYear = year;
}
public void setDate(int month, int day, int year)
{
dMonth = month;
dDay = day;
dYear = year;
}
public int getMonth()
{
return dMonth;
}
public int getDay()
{
return dDay;
}
public int getYear()
{
return dYear;
}
public String toString()
{
return (dMonth + "-" + dDay + "-" + dYear);
}
}
-Set the Month
-Set the Day
-Set the Year
-Return the Month
-Return the Day
-Return the Year
-Test whether the year is a leap year
-Return the number of days in the month. For example, if the date is 3-12-2005, the number of days to be returned is 31 because there are 31 days in March.
-Return the number of days passed in the year. For example if the date is 3-18-2005, the number of days passed in the year is 77. Note that the number of days returned also includes the current day.
-Return the number of days remaining in the year. For example, if the date is 3-18-2005, the number of days remaining in the year is 288.
-Calculate the new date by adding a fixed number of days to the date. For example, if the date is 3-18-2005 and the days to be added are 25, the new date is 4-12-2005.
-Return a reference to the object containing a copy of the date.
-Make a copy of another date. Given a reference to an object containing a date, copy the data members of the object into the corresponding data members of this object.
-Write the definitions of the methods to implement the operations defined for the class Date.
Please if anyone can help that would be amazing!?!
Comment