Click to See Complete Forum and Search --> : having trouble understanding this


keko2005
04-05-2005, 01:20 AM
hey guys, a quick question, we are learning abstract classes and implementing interfaces. now for our 3rd project we have to use this. i know that you have to overwrite the equals method, and the compareTo method in the comparable interface, im not sure how though. heres the question.

You must modify the Customer class you submitted last time, so that it overrides the equals method from
the Object class, and the compareTo method from the Comparable interface. Equality should be based on
the Customer’s ID number and name. Comparison should be performed on the basis of last name, then first
name, and then ID number.

Khalid Ali
04-05-2005, 10:35 AM
you will need to re-write those methods so that they implement the required tasks as mentioned in the question.
Here is theAPI link for object.equals() (http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#equals(java.lang.Object))
and here is the API link for compareTo() (http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Comparable.html#compareTo(java.lang.Object))

keko2005
04-11-2005, 11:22 AM
thanks for the reply, im not sure i understand though, am i supposed to overwrite the equals method with the customers id number and name. if so, how does that work, being the fact that your comparing a string to and int?