Question: Instructions We learned from lecture slides how to read a UML ( Unified Modeling Language ) diagram. Here we use one to tell us what

Instructions
We learned from lecture slides how to read a UML (Unified Modeling Language) diagram. Here we use one to tell us what class name, member fields, and member methods to code.
-------------------------------------------------
GeoLocation
-------------------------------------------------
- EARTH_RADIUS_MILES` : double =3963.1676
- latitude : double
- longitude : double
-------------------------------------------------
+ GeoLocation()
+ GeoLocation(lat : double, lon : double)
+ setLatitude(lat : double) : void
+ getLatitude() : double
+ setLongitude(lon : double) : void
+ getLongitude() : double
+ distanceFrom(o : GeoLocation) : double
-------------------------------------------------
How to calculate distance of two points on a globe
To measure distance along the surface, we can't just draw a straight line between two points on a spherical shaped object. An explanation is here. We can break down the step for the law of cosines with spheres:
Your distanceFrom() method should:
Convert each object's latitude and longitude value to radians using Math.toRadians().
Apply the steps outlined above to find the arcLength (use the radian lat/lon values). Find geometry methods in the Java API Math class.
Return the arcLength times the Earth's radius in miles.
Testing
Writing a program to test your code is a common practice. YOU WILL NOT TURN IN THE TEST PROGRAM!
A simple way to do this is to open another file, called TestGeo (or whatever), write a main() method that
instantiates a GeoLocation object using the no-arg constructor
print getLatitude() and getLongitude() return values (should be zeros)
call the setters
print again to show values were modified to whatever values you passed in
repeat Steps 1-4 but use the GeoLocation two-arg constructor
find the distance between two GeoLocation objects (estimate the answer to verify your method works)

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!