Question: that's the TwoEndedSLL.java file / TwoEndedSll.java package main; public class TwoEndedSll { // declear the TwoEndedSll private static class Node { private T data; private




that's the "TwoEndedSLL.java" file
/ TwoEndedSll.java package main; public class TwoEndedSll{ // declear the TwoEndedSll private static class Node { private T data; private Node next; Node(T data, Node next){ this.data = data; this.next = next; } } Node head, tail; TwoEndedSll(){ this.head = null; this.tail = null; } // add at Head public void addAtHead(T data){ if(head == null){ head = tail = new Node (data, null); } else{ head = new Node (data, head); } } // add At tail public void addAtTail(T data){ if(tail == null){ head = tail = new Node (data, null); } else{ tail.next = new Node (data, null); tail = tail.next; } } // print the content of liked list public void printContent(){ Node temp = head; System.out.print( "content: [" ); while(temp != null){ System.out.print(temp.data); if(temp != tail){ System.out.print(","); } temp = temp.next; } System.out.println("]"); } } // App.java package main; import java.util.Scanner; public class App{ public void run(){ displayInstructions(); TwoEndedSll list = new TwoEndedSll (); Scanner sc = new Scanner(System.in); System.out.print( "> " ); String str = sc.nextLine(); boolean addInHead = true; // we will read till an emtpy line is not entered while(!str.equals("")){ if(addInHead){ list.addAtHead(str.toLowerCase()); addInHead = false; } else{ list.addAtTail(str.toLowerCase()); addInHead = true; } list.printContent(); System.out.print( "> " ); str = sc.nextLine(); } System.out.println( "Done now! Thanks!" ); } private void displayInstructions(){ System.out.println( "Hi| I'm the Two-Ended List app!" ); System.out.println( "Every word you enter on a line will be added to me in alternating head/tail order." ); System.out.println( ); System.out.println( "I will show you my content after every word" ); System.out.println( "I will stop when you enter an emtpy line." ); System.out.println( "Ready? Start entering words!" ); } }
1. Copy your working Two Endeds11.java file from that drill to the main package of this drill's Eclipse project. 2. Create a SimplelinkedQueue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
