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; privateNode next; Node(T data, Node next){ this.data = data; this.next = next;} } Node head, tail; TwoEndedSll(){ this.head = null; this.tail = null;

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 class that implements the given PlainoldQueue interface. The behaviour of SimpleLinkedQueue is described in the Preamble: i. Use your Two Endedsii class to get this job done - you should be pleasantly surprised at how quickly this goes, because Two Endeds11 does all the heavy lifting! ii. if all the SimplelinkedQueue tests are passing, you can consider your SimplelinkedQueue to be working okay! 3. Complete the App.java run method so that when you run Main.java , the program behaves as expected by the MainTests. i. I've added some useful methods in App.java to make your life easier. Hi! I'm the Simple Linked Queue app! If you enter a + followed by an integer, I will add that number to the queue. If you enter a -, I will remove a number from the head of the queue. I will show you the contents of the queue after every operation. I will stop when you enter an empty line. Ready? Start entering numbers! > +9 H->[9] +11 H->[9, 11][11] +9292 H-> [11, 9292][9292][][] Done now! Thanks! This is just a plain old linked-list-backed queue. The only twist is that it uses Optional (Remember Optional? Sure you do - 'cause you watched the screencast.) Here are some details about the class - SimplelinkedQueue - that you will be making. it will be generic...so you can toss whatever reference type you want in it. it should never be full, so if asked isFull it will always reply false. when you dequeue things, they will be wrapped in an Optional; if you try to dequeue something from an empty SimplelinkedQueue , you'll get an empty Optional back. Contrast that to our ChibiLinkedStack, which threw a NoSuchElementException. it should use your TwoEndedsil under the hood (as one of its instance variables)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!