public class Student implements Comparable { // student id, 1-1000 int sid; Birthday sbirthday; // constructor public Student(int id, Birthday.Month month, int date){ this.sid = id; this.sbirthday = new Birthday(); this.sbirthday.month = month ; this.sbirthday.date = date; } // compare the student according to their birthday. public int compareTo(Student s) { if (this.sbirthday.month.compareTo(s.sbirthday.month) == -1){ return -1; } else if (this.sbirthday.month.compareTo(s.sbirthday.month) == 1){ return 1; } else { if (this.sbirthday.date > s.sbirthday.date){ return 1; } if (this.sbirthday.date < s.sbirthday.date) { return -1; } else { return 0; } } } // display the personal information of a student in such form: // id, month of birthday, date of birthday // e.g. ID: 10, Month: MAY, Date: 11 public void display(){ System.out.println("ID: " + sid + ", Month: " + sbirthday.month + ", Date: " + sbirthday.date); } public static void main(String[] args) { Student a = new Student(1, Birthday.Month.JAN, 7); Student b = new Student(2, Birthday.Month.APR, 5); Student c = new Student(3, Birthday.Month.MAY, 5); a.display(); b.display(); c.display(); System.out.println(a.compareTo(b)); System.out.println(b.compareTo(c)); System.out.println(a.compareTo(c)); } }