Create a java program using Java with LinkedLists
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----------");
}
}
View Answers
Related Tutorials/Questions & Answers:
Create a java program using Java with LinkedListsCreate a
java program using Java with LinkedLists Assignment is --
Question
For this part of the assignment, you will develop a
Java application... that reverses the list in place (that is, does not
create a new copy of the list)
Step 2
Advertisements
How to create first program in Java?How to
create first
program in
Java? Hi,
I am new in
Java programming. Tell me How to
create first
program in
Java?
Thanks
Hi,
Read more at First
Java Program.
Thanks
How to create first Java Program?How to
create first
Java Program? Hi,
I am beginner and I want to write first
Java program. How I can setup my machine and write first
Java program... and run first
Java program:
Create program in Note pad:
Step 1: Open
Create HTML page using java Create HTML page
using java Hi, I need to
create an html page to export some information. Currently, by
using java, i've exported information to excel. But now, I would like to view it in HTML instead of excel. Is there any
LINKEDLISTSLINKEDLISTS HOW TO DELETE,INSERT & PRINT NODES IN LIKEDLISTS
Hi Friend,
Please visit the following links:
http://www.roseindia.net/java/jdk6/LinkedListExample.shtml
http://www.roseindia.net/
java/beginners
java program using control statements...java program using control statements... public class ControlStatements {
public static void main(String args[]){
int x=10;
if(x==0...("It is negative number");
}}}
in this
program what and where it is error and why
Java Program Qns using BlueJJava Program Qns
using BlueJ Write a
program that accepts one...), showing the carry, the quotient and the remainder.
The
program should output... are 158 and 7, the
program should output:
1 1
7) 1 5 8
0 2 2 R4
If the two
create and use an array variable in a java programcreate and use an array variable in a
java program how do i write a
program that will prompt the user for a list of 5 prices, once the user has entered all values , your
program should compute and display the following: The sum
Create Excel Sheet Using JSP
create excel sheet
using jsp
In this
program, we are going to
create the cells and
rows into excel sheet
using
java .You can
create any number of cells and rows
How to create new arraylist using JavaHow to
create new arraylist
using Java hi,
I want to develop... someone provides online example how to
create new arraylist in
java programming.
thnaks,
Hi,
In
java programming language you can
create new
Create a Java program using XSLT APIs Create a
Java program using XSLT APIs
Now we will develop a class in
Java that takes both XML...(e.getLocationAsString());
}
}
This
program uses three
Execute the java program using one processorExecute the
java program using one processor
Write a
program to print the number series 1, 2,3, 4�.100
using java programming language in dual core computer
a) Execute the
program using one processor
b) Execute
want a program for date picker by using java swingswant a
program for date picker by
using java swings to write a
program for the date picker by
using java swings.any one please help me by providing the code to this
java date picker by
using the
java swings.previously a
program how to run a java program using run.exec()?how to run a
java program using run.exec()? Hi..i want to compile and run a
java file
using run.exec().i.e., without compiling and running from....
can i expect a sample
java program using run.exec().
Thanking you
Sending and receiving xml message using Java ProgramSending and receiving xml message
using Java Program Hi Friends,
I want to send and receive xml files between two
java programs
using wire format... sample
program to understand.
Thanks in advance.
Regards,
Atul Patil
Sending and receiving xml message using Java ProgramSending and receiving xml message
using Java Program Hi Friends,
I want to send and receive xml files between two
java programs
using wire format... sample
program to understand.
Thanks in advance.
Regards,
Lisha Ahuja
Program using String functions - Java BeginnersProgram using String functions Write a
program to accept a sentence and find out how many times the word "the" occurs? Hi Friend,
Try the following code:
import java.util.*;
class CountSameWords
How to create Multiple Frames using Java SwingMultiple Frames in
Java Swing
In this section, you will learn how to
create multiple frames.
Java Swing provides the utility to show frame within another frame by providing the class JInternalFrame. With the use of this class, you can
Create Tabs in Java using SWT
Create Tabs in
Java using SWT
This Tab Example in
Java, will teach you how to
create tabs
using SWT in
Java. After going through the example you will be able to
create Java Create Directory - Java Tutorial
Java Create Directory -
Java Tutorial
... a directory or
subdirectories are created. This
program also explains the process...;}
}
Output of the
program:
C:\nisha>javac CreateDirectory.java
How to Create Excel Page Using JSP using
java .By going through the steps of this example we can
create any...
using pure word files
using Java.
We can
create, read or write MS Excel file
using...
how to
create excel page
using jsp
how to create xml schema from xml doc using javahow to
create xml schema from xml doc
using java i want to
create xml schema from xml document programatically
using java... am
using Netbeans IDE... need to
create the xml schema for that document and send both xml doc ans schema
plz help me to create gui using Java netbeansplz help me to
create gui
using Java netbeans Hi,
I am unable to fetch a particular data from DB.I am
using netbeans for creating GUI. If I want to fetch a particular value like '6', it is calling all the data which contains 6
Create Scroll Bar in Java using SWT
Create Scroll Bar in
Java using SWT
... SWT
The given example will show you how to
create scroll bar in
Java using... a package org.eclipse.swt.widgets, which is used
to
create ScrollBar in
Java