public int compareTo(Object x) {
Task other = (Task)x;
if (other.priority == this.priority) {
System.out.println("Each task has the same priority level.");
return 0;
} else if (other.priority > this.priority) {
System.out.println(other.priority + "\n" + this.priority);
return -1;
} else {
System.out.println(this.priority + "\n" + other.priority);
return 1;
}
}
That's the code I have for a programming assignment for class. I'm not sure why I use Task other = (Task)x;
or what it's doing here. The rest I understand. If anyone has a quick explanation of what that's actually doing here I would be greatful. Thank you!