In this problem, we are going to use ArrayLists and classes to design a road trip. You have three classes: GeoLocation.java which represents a geo location. A RoadTrip.java class, which represents a road trip (or an ordered list of places), and a RoadTripTester.java class which brings them all together. In GeoLocation.java: Add a private instance variable called name which is a String. This represents the name of the location. Modify the Geolocation class constructor so that it is now of the format public GeoLocation(String name, double theLatitude, double theLongitude) Add a getter method for name called getName(). Update the toString so that it returns a String of the format San Francisco (37.7833, -122.4167) Now, you’ll also need to create a RoadTrip class. RoadTrip stores an ordered list of locations, so you’ll need to have an ArrayList as an instance variable. The RoadTrip class constructor should initialize an ArrayList that stores a list of GeoLocations. You’ll also need to support these methods. // Create a GeoLocation and add it to the road trip public void addStop(String name, double latitude, double longitude) // Get the total number of stops in the trip public int getNumberOfStops() // Get the total miles of the trip public double getTripLength() // Return a formatted toString of the trip public String toString() We’ve given you a tester program to help get you started. The output from that program would be: 1. San Francisco (37.7833, -122.4167) 2. Los Angeles (34.052235, -118.243683) 3. Las Vegas (36.114647, -115.172813) Stops: 3 Total Miles: 572.970885044270

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In this problem, we are going to use ArrayLists and classes to design a road trip.

You have three classes: GeoLocation.java which represents a geo location. A RoadTrip.java class, which represents a road trip (or an ordered list of places), and a RoadTripTester.java class which brings them all together.

In GeoLocation.java:

Add a private instance variable called name which is a String. This represents the name of the location.

Modify the Geolocation class constructor so that it is now of the format

public GeoLocation(String name, double theLatitude, double theLongitude)

Add a getter method for name called getName().

Update the toString so that it returns a String of the format

San Francisco (37.7833, -122.4167)

Now, you’ll also need to create a RoadTrip class. RoadTrip stores an ordered list of locations, so you’ll need to have an ArrayList as an instance variable. The RoadTrip class constructor should initialize an ArrayList that stores a list of GeoLocations.

You’ll also need to support these methods.

// Create a GeoLocation and add it to the road trip public void addStop(String name, double latitude, double longitude) // Get the total number of stops in the trip public int getNumberOfStops() // Get the total miles of the trip public double getTripLength() // Return a formatted toString of the trip public String toString()

We’ve given you a tester program to help get you started.

The output from that program would be:

1. San Francisco (37.7833, -122.4167) 2. Los Angeles (34.052235, -118.243683) 3. Las Vegas (36.114647, -115.172813) Stops: 3 Total Miles: 572.9708850442705

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education