class Person { protected String name; protected Date dateOfBirth; public Person(int d,int m,int y,String n) throws PersonException { try { name=n; dateOfBirth = new Date(d,m,y); } catch(DateException e) { throw new PersonException("Invalid date-of-birth: "+ e.getMessage()+" for "+n); } } public String toString() { return "Name: "+name+"\nDate of birth: "+dateOfBirth+"\n"; } public boolean older(Person p) { return dateOfBirth.lessThan(p.dateOfBirth); } public boolean older(Date d) { return dateOfBirth.lessThan(d); } public boolean beforeAlphabetically(Person p) { return name.compareTo(p.name)<0; } }