Question: IN JAVA PLS Create a public class named Position. Position should define a single public constructor that accepts two fields: a latitude and longitude value,

IN JAVA PLS

Create a public class named Position. Position should define a single public constructor that accepts two fields: a latitude and longitude value, as double values, in that order. Your constructor should reject invalid latitude and longitude values. Valid longitude values are between -180.0 and 180.0, inclusive, while valid latitude values are between -90.0 and 90.0, inclusive.

Position should also implement the Java Comparable interface, returning 1 for a positive result and -1 for a negative result. An instance of Position is greater than a second instance if it is closer to either the North or South Pole, is lesser than the second instance if it is farther from the North or South Pole, and equal if it is at the same distance. The instance passed to compareTo will not be null.

You will probably need to review the documentation for Comparable. Because we are using the type parameter Position to the Comparable interface, compareTo accepts an Position as an argument.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!