I have a doubt regarding the implementation of equals and hashcode methods.In some previous posts it has been said that we could compare them with record numbers.
1.Is there any possiblity that the record Number is different or might not exist.I could not think of such situation.If it is so please convey it to me.
Some have suggested by combining both the contractor name and City.I have a doubt for this.Why not two contractors having the same name could live in a same city.If so how should we know the uniqueness of a record be checked.
2.Is the verification based on the record number alone is okay or is any other idea is better
I am using recrod numbers i.e offsets form the start of file for search method and make Stirng comparision.
but I think I will need equals and hashcode for create method, if I don't leave the responsibility on the user not to create duplicate record.
And, It is possible(and ok to assume) to have two contractors with same name in a city, You can include "rate" and "number of people" fields into your hashcode and equals implimentation, THEN it will be very rare to have contractor with same name, in same city, with same rate, with same number of people working with the contractor.