Question
I need help understanding this JAVA hw problem: A mapping software package creates routes between locations on the Earths surface. Locations are represented by objects
I need help understanding this JAVA hw problem:
A mapping software package creates routes between locations on the Earths surface. Locations are represented by objects of the Location class.
The declaration for the Location class is shown below. It includes a method which returns the shortest distance in meters between the current Location object and another Location object.
public class Location { /** @return distance, in meters, between this location and other * Postcondition: distance returned is greater than or equal to 0 */ public double distTo(Location other) { /* */ }
// There may be instance variables, constructors, and methods that are not shown. }
A route consists of an ordered sequence of locations, with the first being a starting point and the last being the destination. The route is followed by taking the shortest path from each location to the next in the sequence. A route is represented by an object of the Route class, which contains a List of Location objects in the order that those locations appear in the route. A partial declaration of the Route class is shown below. You will write two methods for the Route class.
public class Route { /** The list of locations which make up the route: the route goes from each location to the * the next in the list by the shortest possible path */ private List waypoints;
/** @return the total distance of the route in meters, travelling from each location to the * next in order, using the shortest path between adjacent points in the route */ public double getTotalDistance() { /* to be implemented in part (a) */ }
/** @return the shortest distance in meters between any two points on the route (note: * these points need not be adjacent) */ public double shortestDistance() { /* to be implemented in part (b) */ }
// There may be instance variables, constructors, and methods that are not shown. }
Complete Route method get TotalDistance below. /** @return the total distance of the route, traveling from each 1 ocation to the next in order, using the shortest path between adjacent points in the r oute public double getTotalDistance) Complete Route method get TotalDistance below. /** @return the total distance of the route, traveling from each 1 ocation to the next in order, using the shortest path between adjacent points in the r oute public double getTotalDistance)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started