Answer :
Final answer:
To modify the compareTo method to account for the course numbers, assign numerical values to the courses and compare them. If the course numbers are equal, compare the priorities assigned to those course numbers.
Explanation:
In order to modify the compareTo method to account for the course numbers, we need to establish a priority order for the courses 1000, 2000, and 3000. We can do this by assigning numerical values to the courses, with 3000 being the highest priority, 2000 being the second highest, and 1000 being the lowest. In the compareTo method, we can compare the course numbers first, and if they are equal, we can compare the priorities assigned to those course numbers to determine the order.
Here is an example of how the modified compareTo method could look:
public int compareTo(Assignment other) {if (this.dueDate.equals(other.dueDate)) {
if (this.courseNumber == other.courseNumber) {
return Integer.compare(this.priority, other.priority);
}
return Integer.compare(other.courseNumber, this.courseNumber);
}
return this.dueDate.compareTo(other.dueDate);
}