83.5k views
1 vote
/** What is a method that Determines whether this Date is before the Date d.

* @return true if and only if this Date is before d.
*/
public boolean isBefore(Date d) {
if(this.date.isBefore(d))
{
// replace this line with your solution
}

/** Determines whether this Date is after the Date d.
* @return true if and only if this Date is after d.

public boolean isAfter (Date d)

{
}
*/
public boolean isAfter(Date d) {
// replace this line with your solution
}

/** What is a method that Returns the number of this Date in the year.
* @return a number n in the range 1...366, inclusive, such that this Date
* is the nth day of its year. (366 is used only for December 31 in a leap year)

public int difference (date d)
* year.)
*/
public int dayInYear() {

return 0;


}

/** Determines the difference in days between d and this Date. For example,
* if this Date is 12/15/2012 and d is 12/14/2012, the difference is 1.
* If this Date occurs before d, the result is negative.
* @return the difference in days between d and this date.
*/
public int difference(Date d) {
return 0; // replace this line with your solution
}

User Willw
by
5.1k points

1 Answer

5 votes

Answer:

Following is given the solution to the question. This question has two parts of source code:

  • Date class
  • Main class

The images are attached displaying code or each class. Indentations are made clear so that the code get easier to understand.

Comments are given inside the code where necessary to make the logic clear.

Output for the code is also attached in the last image.

Step-by-step explanation:

I hope it will help you!

/** What is a method that Determines whether this Date is before the Date d. * @return-example-1
/** What is a method that Determines whether this Date is before the Date d. * @return-example-2
/** What is a method that Determines whether this Date is before the Date d. * @return-example-3
User Xiaokun
by
5.5k points