Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. }

image text in transcribed

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

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

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

What is audit risk? Discuss.

Answered: 1 week ago

Question

1. Ask students to put their names on the backs of their papers.

Answered: 1 week ago

Question

4. Identify cultural variations in communication style.

Answered: 1 week ago

Question

9. Understand the phenomenon of code switching and interlanguage.

Answered: 1 week ago

Question

8. Explain the difference between translation and interpretation.

Answered: 1 week ago