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
EARTHRADIUSMILES : double
latitude : double
longitude : double
GeoLocation
GeoLocationlat : double, lon : double
setLatitudelat : double : void
getLatitude : double
setLongitudelon : double : void
getLongitude : double
distanceFromo : 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 latlon 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 noarg 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 but use the GeoLocation twoarg 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
