Assignment is --
Question
For this part of the assignment, you will develop a Java application with a simple text-based interface that will allow a user to work with a doubly-linked list representing train routes. Read through all the steps before beginning, and although there are no marks for it, we do recommend making a plan first as well.
Step 1 Your first task is to update the singly-linked list we saw in class to be a doubly-linked list. You may start with the actual code presented in class. Ensure the following requirements are met: Each list node must include a reference to the prev node All four of the linked list�s add and remove methods must update the prev reference
The copy methods must correctly copy the prev references You must add a new method to the linked list that reverses the list in place (that is, does not create a new copy of the list) Step 2 Next, you will update your linked list and list nodes.
The list itself should have a String that refers to the train route�s name . The list will now contain nodes that store information about stops along a route.
Each list node will refer to a class representing a single stop along a train route [1 mark]. Stop information should include the name and location of the stop. Information about amenities at the stop should also be included, such as whether it�s a full station or just a small shelter, whether there are washrooms available, and anything else you think is relevant . The stop should have a useful toString method , and an equals method that checks whether the stop�s name and location are equal .
In your linked list class, add at least two static methods that will each construct and return a new linked list for a specific train route . These are handy helper methods that will allow you to generate lists for testing quickly and easily.
Test all of the linked list methods with the linked lists from your static helpers in a main method inside a class called TestLinkedList .
Step 3 Now you will create a user interface class named RouteUI that follows the separated presentation design shown in class. Your user interface will know about the linked list, but your linked list must not know about the user interface (marks will be deducted if you don�t follow this).
Inside your RouteUI class, you will store an array (or ArrayList, if you prefer) of train routes In other words, you are essentially storing a list of lists.
Your RouteUI class will have a main method that, when run, will cause a text-based menu to appear with the following options Create a train route. Load default train routes. Find fastest route to stop. Quit.
When creating a train route, ask the user what the route is called, then have the user input information about stops until they type ââ?¬Å?doneââ?¬Â? . Create the linked list as the information is entered and add the route to the UI classââ?¬â?¢s list . Copy and reverse the list, add ââ?¬Å?-Reverseââ?¬Â? to its name, and add it to the UI classââ?¬â?¢s list .
Loading the default train routes means adding the routes from the static helper methods and their reverses to the UI class�s list (without overwriting the old stuff), ensuring they weren�t already there .
When the user wants to find the fastest route to a particular stop, they should be asked to name the stop and its location. Then, this information should be used to find the route that has the fewest number of stops from the beginning to the stop provided [3 marks]. If a route was found, the program will output the names and locations of the stops from the beginning to the requested stop .
Demonstrate that your UI works by testing each functionality, then save the text of your interactions and include them in a file called testing-output.txt [2 marks]. This testing file will be used somewhat to evaluate your work (though if it appears you have modified it at all after copying the text of your interactions, you will lose 50% of your marks for this part of the assignment).
Question guideLine
public class ListNode { private Scene data; private ListNode next;
public ListNode(Scene newData) { this(newData, null); } public ListNode(Scene newData, ListNode newNext) { data = newData; next = newNext; } public Scene getData() { return data; } public ListNode getNext() { return next; } public void setNext(ListNode newNext) { next = newNext; } public void printListFromHere() { System.out.println("----------\nStart List\n----------"); ListNode currNode = this; while (currNode != null) { System.out.println("\t" + currNode.getData()); currNode = currNode.getNext(); } System.out.println("----------\nEnd List\n----------"); }
}
Ads