Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions