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

In the assignment, my professor asked us to create a class named Date2 and creat

ID: 3541260 • Letter: I

Question

In the assignment, my professor asked us to create a class named Date2 and create three global variables: month, day, year. All the variables are integers. So I created the proper constructors as requested and overwrote the copy method and toString. However, I do not understand the following part of the assigment:
  • An equals method returns true if the passed Date2 object matches the current Date2 object, field value for field value.

In the assignment, my professor asked us to create a class named Date2 and create three global variables: month, day, year. All the variables are integers. So I created the proper constructors as requested and overwrote the copy method and toString. However, I do not understand the following part of the assigment:

Explanation / Answer

   
class Date2
{
public int month;
public int day;
public int year;
public boolean equals(Date2 passed)
{
// you are looking for below code snippet;
// u should return true only when month is same as passed month, day is same as passed day and year same as passed year.
// add this function to your class to get it complete.
return (month==passed.month && day==passed.day && year==passed.year);
}
}




Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote