Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

public class Date { public Date(int month, int day, int year); public boolean co

ID: 3620675 • Letter: P

Question

public class Date {
public Date(int month, int day, int year);
public boolean comesBefore(Date d);
public Date nDaysLater(int n);
public Date nDaysEarlier(int n);
public int daysBetween(Date d);
public String toString();
}

You must use the class and method signatures shown. the method, the type and order of the parameters, and the method's return type. You may choose how the date is internally represented within the class, i.e. what fields the class contains. Add your own main method to the class. In main, you should create Date objects and use them to test all the methods shown above. Testing each method once is not enough! Try working with dates that are very close and others that are widely separated. Thirty days hath September, April, June, and November... all the rest have 31 except February which has 28 days, or in leap year 29. Please treat years divisible by 4 as leap years.
This class represents a date on the calendar. It has one constructor. If the constructor is asked to create an invalid date (e.g. 10/40/2010) it should raise an IllegalArgumentException:
throw new IllegalArgumentException("Invalid Month");
The exact wording of the error message is up to you. Be informative.

comesBefore should return true if the first Date comes before the second, as in Date jan1 = new Date(1,1,2000); Date jan2 = new Date(1,2,2000); if (jan1.comesBefore(jan2)) // this should return true

nDaysLater and nDaysEarlier produce Date objects that are either after or before the existing Date (which is not changed).
For example, jan1.nDaysLater(1) should return the Date 1/2/2000 and jan2.nDaysEarlier(2)should return the Date 12/31/1999. Raise an IllegalArgumentException if n is negative. (n = 0 is fine).
jan1.daysBetween(jan2) should return 1. jan2.daysBetween(jan1) should also return 1 (not -1) and jan1.daysBetween(jan1) should return 0.
The toString method should return a string representation of the calling Date object. The format of the string should be “10/4/2010”, with the month first.
You may create additional „helper? methods in this class if you choose. Such methods should be declared „private?. A reasonable way to add 200 days to a date is to add one day 200 times. This is not the most efficient solution, but it is acceptable for this assignment.

Explanation / Answer

So what's your problem exactly? You need to write your own work.