import java.util.*; // Comparator interface is part of this package // see DateWithComparison.java for comments, this only differs by adding Comparator and compares and equals method public class DateWithComparison2 implements Comparator, Comparable { private int day, month, year; public DateWithComparison2() { day=1; month=1; year=1970; // this date is known as the epoch in Unix/Linux systems } public DateWithComparison2(int d, int m, int y) { day=d; month=m; year=y; } public int getDay() {return day;} public int getMonth() {return month;} public int getYear() {return year;} public void setDay(int d) {day=d;} public void setMonth(int m) {month=m;} public void setYear(int y) {year=y;} public String toString() { return month + "/" + day + "/" + year; } public int compare(Object o1, Object o2) // receives two Objects, hopefully both are DateWithComparison2's { int d1=((DateWithComparison2)o1).getDay(); // need to downcast, store each day, month and year in separate int d2=((DateWithComparison2)o2).getDay(); // variables for ease later int m1=((DateWithComparison2)o1).getMonth(); int m2=((DateWithComparison2)o2).getMonth(); int y1=((DateWithComparison2)o1).getYear(); int y2=((DateWithComparison2)o2).getYear(); if(y1y2) return 1; else if(m1m2) return 1; else if(d1d2) return 1; else return 0; } public boolean equals(Object o) { if(this.compareTo(o)==0) return true; // call on compareTo (or we could have used compare(this, o) to do the work else return false; // if it returns 0, we know the Dates are the same } public int compareTo(Object o) { int otherDay=((DateWithComparison)o).getDay(); int otherMonth=((DateWithComparison)o).getMonth(); int otherYear=((DateWithComparison)o).getYear(); if(year>otherYear) return 1; else if(yearotherMonth) return 1; else if(monthotherDay) return 1; else if(day