I'm working with hashCode for the first time and not sure how to check if two objects are equal. This is what I have so far.
/** Represents a City */
class City {
/** Decimal format to print leading zeros in zip code */
static DecimalFormat zipFormat = new DecimalFormat("00000");
int zip;
String name;
String state;
double longitude;
double latitude;
/** The full constructor */
public City (int zip, String name, String state,
double longitude, double latitude) {
this.zip = zip;
this.name = name;
this.state = state;
this.longitude = longitude;
this.latitude = latitude;
}
/** to make sure the two cities have the same name, state, zip code,
* and the same latitude and longitude */
public boolean equals(Object obj){
if (obj == null)
return false;
City temp = (City)obj;
System.out.println(City.equals(obj));
}