QuestionQuestion

Transcribed TextTranscribed Text

Multi-Linked Lists: Wanderlust! What the program must accomplish: Imagine that you're going to keep track of some data. In this case, you're going to keep track of a collection of travel destinations. Each attraction has a name (a string), a location (more strings for city and country), and a distance (a double). For this assignment, you're going to create a program that will manage a linked list of travel attractions. There's a twist, however - each node in the linked list will actually have TWO next pointers, so that you can have two 'lists' stored in the same place. There's going to be list for the attractions, sorted according to name, and there's going to be a second list, sorted according to location (city/country). A picture of how this might look is given below: Abroction by Attraction by Name Lutation Name: Name: tiffel Empire State lower Name: Building Next by Gulden Gate Next by Name Bridge Name Next ny City: Nees City: Paris Name York Next by City: San Next by Francisco Incation Country: Next by France location Country: USA Country: Distance: USA Distance: Distance: Notice how each Attraction has a 'next by name' AND a "next by location' reference. Thus, if we were to print the attractions by following the links in the attraction list, we'd get: Attraction Name: Eiffel Tower Attraction City: Paris Attraction Country: France Distance from Seattle: 4996. 44 Attraction Name: Empire State Building Attraction City: New York Attraction Country: USA Distance from Seattle: 2401.76 Attraction Name: Golden Gate Bridge Attraction City: San Francisco Attraction Country: USA Distance from Seattle: 679.26 Likewise, if we were to print the attractions by following the links in the city list, we'd get: Attraction Name: Empire State Building Attraction City: New York Attraction Country: USA Distance from Seattle: 2401.76 Attraction Name: Eiffel Tower Attraction City: Paris Attraction Country: France Distance from Seattle: 4996. 44 Attraction Name: Golden Gate Bridge Attraction City: San Francisco Attraction Country: USA Distance from Seattle: 679.26 You need to implement a program that will allow someone to add a destination, remove a destination, and print the destinations (Attractions) by either name or location. In addition, provide load and save feature for loading and saving Attractions to from a file (destinationlist.txt). The Attraction objects must be stored in the multi-linked lists' described above. If you have two attractions with the same name, then they should be put into sorted based on their different locations (and likewise with attractions in the same location, sort by name). Do NOT allow duplicate Attractions (same name and same location) to be added. To be clear: you need to implement not just the data structures that store this information, but you also need to finish implementing the Console-based user interface that will allow the user to interactively create destinations, print the list, and remove destinations.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class Attraction {
    private String name;
    private String city;
    private String country;
    private double distance;   
   
    /**
    * constructor
    * @param name
    * @param city
    * @param country
    * @param distance
    */
    public Attraction(String name, String city, String country, double distance) {
       this.name = name;
       this.city = city;
       this.country = country;
       this.distance = distance;
    }

    /**
    *
    * @return string expression of the attraction
    */
    @Override
    public String toString() {
       String expression = "";
       expression = "Attraction Name: " + name + "\n" +
                        "Attraction City: " + city + "\n" +
                        "Attraction Country: " + country + "\n" +
                        "Distance from Seattle: " + distance + "\n";
       return expression;
    }...
$45.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats