Question: Language/Type: Related Links: Author: Java classes Comparable compare To interfaces implementing instance methods Location.java Marty Stepp Suppose that a class Location has been defined for

Language/Type: Related Links: Author: Java classes Comparable compare To interfaces implementing instance methods Location.java Marty Stepp Suppose that a class Location has been defined for storing information about global map locations. Each location keeps track of its name (a string), its latitude (a real number), and its longitude (a real number). The class includes the following members: Name private String name private double latitude private double longitude public Location(String name, double latitude, double longitude) public String getName() public double getLatitude) public double getLongitude) public String toString() Description name of location location's latitude location's longitude constructs a location with given name, latitude, longitude returns the name returns the latitude returns the longitude returns a String representation of the location Your task is to modify the class to be comparable by adding an appropriate compare to method. Locations should be ordered first by latitude with locations closer to the equator considered less than locations farther from the equator. When the latitudes are equal, you should examine longitudes with locations closer to the prime meridian considered less than locations farther from the prime meridian. Latitudes are expressed relative to the equator with negative latitudes considered to be in the southern hemisphere and positive latitudes considered to be in the northern hemisphere. Thus, 0 represents the equator, -90 represents the South Pole and 90 represents the North Pole. Longitudes are expressed relative to what known as the prime meridian (the line of longitude that runs through Greenwich, England), with positive longitudes considered to be in the western hemisphere and negative longitudes considered to be in the eastern hemisphere. Longitudes can range from - 180 to 180. You may assume that your constructor is passed legal values for latitude and longitude. You are allowed to use the Math.abs method to find the absolute value of a number
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
