Question: Need some assistance in java Here is my Place.java code: public class Place { private String studentName; private String name; private String description; GeoLocation location;
Need some assistance in java
Here is my Place.java code:
public class Place { private String studentName; private String name; private String description; GeoLocation location; public Place(String name,String description,double latitude,double longitude) { this.name = name; this.description = description; this.location = new GeoLocation(latitude,longitude); } public void setName(String name) { this.name = name; } public String getName() { return name; } public void setDescription(String description) { this.description = description; } public String getDescription() { return description; } public void setLocation(double latitude,double longitude) { location.setLatitude(latitude); location.setLongitude(longitude); } public void setLocation(GeoLocation location) { this.location = location; } public GeoLocation getLocation() { return location; } public String toString() { return name+" "+ "(latitude:"+location.getLatitude()+ "," +"longitude:"+location.getLongitude()+")"; } }
Instructions Change your getldentificationString0method to return "Program 5b, Your Name Have your Place class implement the Comparable interface to allow it to be compared to other Places. Create the public int compare To(Place otherPlace) method, that will return an int based off how the current Place compares to the one passed in o The method should return a negative number, 0, or a positive number depending on if the current Place is less than, equal to, or greater than the other Place respectively. o A Place is less than, equal too, or greater than another Place depending on their names (Hint: The String class implements Comparable as well) Add an equals method to your Place class (public boolean equals (Place otherPlace) that returns true f the locations in both places are equal based on their coordinates (Remember to re-use code you may already have!) Next, you will be creating a new driver class to test your code: PlacesToGo o Within this class, create an ArrayList of Places and add the following to it (note the different classes) Place "New York "One very large city", 100.2, 150.1283) Place ("Los Angeles", "City of angels, 54.89 -100.30) Eatery ("Chilis", "American sized food, 36.265, 127.387, "American, 30, 3) Eatery( Panda Express", "My Favorite Place", -117.479, -27.968, "Chinese", 10, 4) Attraction County Fair", "Janky rides", -23.27, 237.387, 25, 30 Attraction San Diego Zoo", "Harambe lives in our hearts", -45.27, 28.39, 40, 1) o Print out this list using a for loop, with each Place printed on a new line. After all Place's have been printed, print an extra empty ne o Sort the Array list by using Collections.sortArrayList) The purpose of this is to test that your compareTo0 method works correctly, as it uses this method to sort the list o Print out the list again one more time in the same fashion, but without the extra line afterwards. Documentation and Neatness (14 Points!!!)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
