Answered step by step
Verified Expert Solution
Question
1 Approved Answer
java please Activities Implement the compareTo ( ) method in the Location class. You may use whatever criteria you wish ( city / state or
java please
Activities
Implement the compareTo method in the Location class. You may use whatever criteria you wish
citystate or latitudelongitude etc.
Implement the insertionSort and quickSortRecursive methods in the SortingAlgorithms class. Do
this by adapting the algorithms as presented in your text book or other resource algorithms are also available
in our CS textbook.
package unl.cse.sorting;
public class Location implements Comparable
private final String zipCode;
private final String city;
private final Double latitude;
private final Double longitude;
private final String state;
public LocationString zipCode, Double latitude, Double longitude, String city, String state
this.zipCode zipCode;
this.city city;
this.latitude latitude;
this.longitude longitude;
this.state state;
public String getCity
return this.city;
public String getZipCode
return this.zipCode;
public Double getLatitude
return latitude;
public Double getLongitude
return longitude;
public String getState
return state;
Complete the implementation of this method that will be used for sorting
collections of Locations.
@param l
@return
@Override
public int compareToLocation l
throw new UnsupportedOperationExceptionYOU MUST IMPLEMENT THIS";
@Override
public String toString
StringBuilder sb new StringBuilder;
sbappendthisgetCity;
sbappend;
sbappendthisgetState;
sbappend;
sbappendthisgetZipCode;
return sbtoString;
@Override
public boolean equalsObject obj
return obj null && obj instanceof LocationthiscompareToLocation obj : false;
@Override
public int hashCode
final int prime ;
int result ;
result prime result city null : city.hashCode;
result prime result latitude null : latitude.hashCode;
result prime result longitude null : longitude.hashCode;
result prime result state null : state.hashCode;
result prime result zipCode null : zipCode.hashCode;
return result;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started