Hi i need an implementation on the LinkListDriver and the LinkListOrdered for this output : Enter your choice: 1Enter element: MaryList Menu Selections1. add element2_remove element3.head...

Hi i need an implementation on the LinkListDriver and the LinkListOrdered for this output : Enter your choice: 1 Enter element: Mary List Menu Selections 1. add element 2_remove element 3.head element 4. display 5.Exit Enter your choice: 3 Element @ head: Mary List Menu Selections 1-add element 2-remove element 3_head element 4.display 5-Exit Enter your choice: 4 1. Mary List Menu Selections 1. add element 2. remove element 3.head element 4. display 5. Exit Enter your choice: LinkedListDriver package jsjf; import java.util.LinkedList; import java.util.Scanner; public class LinkedListDriver {         public static void main(String [] args)         {                 Scanner input = new Scanner(System.in);                 LinkedList list = new LinkedList();                 int menu = 0;                 do {                         System.out.println("\nList menu selection\n1.Add element\n2.Remove element\n3.Head\n4.Display\n5.Exit");                         System.out.println();                         System.out.print("Enter your choice: ");                         menu = Integer.parseInt(input.next());                                                                       switch (menu) {                         case 1:                     System.out.print("Enter Element: ");                     String Element = input.next();                                 break;                         case 2:                              System.out.print("Enter Element: ");                     Element = input.next();                     break;                         case 3:                               System.out.print("Enter Element: ");                     Element = input.next();                                 break;                         case 4:   System.out.print("Enter Element: ");                     Element = input.next();                                 break;                         }                 } while (menu != 5); // iterates until 5 (Exit) is entered                 input.close();         } } Linear Node package jsjf; public class LinearNode {     private LinearNode next;     private E element;     /**      * Creates an empty node.      */     public LinearNode()     {         next = null;         element = null;     }     public LinearNode(E elem)     {         next = null;         element = elem;     }        public LinearNode getNext()     {         return next;     }     /**      * Sets the node that follows this one.     public void setNext(LinearNode node)     {         next = node;     }     /**      * Returns the element stored in this node.      *      * @return the element stored in this node      */     public E getElement()     {         return element;     }     /**      * Sets the element stored in this node.      *      * @param elem the element to be stored in this node      */     public void setElement(E elem)     {         element = elem;     } } LinkedOrderedList package jsjf; import java.util.Iterator; import java.util.Spliterator; import java.util.function.Consumer; import jsjf.exceptions.*; public class LinkedOrderedList extends LinkedList implements OrderedListADT { public LinkedOrderedList()    {        super();    } public void add(T element, LinearNode tail)    {             if (!(element instanceof Comparable))                 {                     throw new NonComparableElementException("LinkedOrderedList");                 }             else                 {                     Comparable comparableElement = (Comparable)element;                 LinearNode head = null;                     LinearNode current = head;         LinearNode previous = null;         LinearNode newNode = new LinearNode(element);         boolean found = false;       if (isEmpty()) // list is empty                         {                             head = newNode;             tail = newNode;                         }                     else if (comparableElement.compareTo(head.getElement()) = 0)// element goes at tail                         {                             tail.setNext(newNode);             tail = newNode;                         }                     else // element goes in the middle                         {                             while ((comparableElement.compareTo(current.getElement()) > 0))                                 {                                     previous = current;                 current = current.getNext();                                 }                             newNode.setNext(current);             previous.setNext(newNode);                         }                 int count = 0;                     count++;                 int modCount = 0;         modCount++;                 }    }     @Override     public T removeFirst() {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public T removeLast() {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public T remove(T element) {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public T first() {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public T last() {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public boolean contains(T target) {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public boolean isEmpty() {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public int size() {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public Iterator iterator() {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public void forEach(Consumer action) {         OrderedListADT.super.forEach(action); //To change body of generated methods, choose Tools | Templates.     }     @Override     public Spliterator spliterator() {         return OrderedListADT.super.spliterator(); //To change body of generated methods, choose Tools | Templates.     }     @Override     public void add(T element) {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     } } Linked List  //Explanation is added in comments import java.util.Scanner; public class LinkedList { Scanner keyboard = new Scanner(System.in); //head will represent starting point Node head; // head to store starting point of list private class Node { // nested class to define nodes int data; Node next; } public void build(){ System.out.println("Enter number of nodes in the list.\n"); int N=keyboard. nextInt(); // N is number of nodes LinkedList list=new LinkedList(); for (int i=0;i extends LinkedList implements OrderedListADT { public LinkedOrderedList()    {        super();    } public void add(T element, LinearNode tail)    {             if (!(element instanceof Comparable))                 {                     throw new NonComparableElementException("LinkedOrderedList");                 }             else                 {                     Comparable comparableElement = (Comparable)element;                 LinearNode head = null;                     LinearNode current = head;         LinearNode previous = null;         LinearNode newNode = new LinearNode(element);         boolean found = false;       if (isEmpty()) // list is empty                         {                             head = newNode;             tail = newNode;                         }                     else if (comparableElement.compareTo(head.getElement()) = 0)// element goes at tail                         {                             tail.setNext(newNode);             tail = newNode;                         }                     else // element goes in the middle                         {                             while ((comparableElement.compareTo(current.getElement()) > 0))                                 {                                     previous = current;                 current = current.getNext();                                 }                             newNode.setNext(current);             previous.setNext(newNode);                         }                 int count = 0;                     count++;                 int modCount = 0;         modCount++;                 }    }     @Override     public T removeFirst() {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public T removeLast() {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public T remove(T element) {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public T first() {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public T last() {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public boolean contains(T target) {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public boolean isEmpty() {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public int size() {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public Iterator iterator() {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     }     @Override     public void forEach(Consumer action) {         OrderedListADT.super.forEach(action); //To change body of generated methods, choose Tools | Templates.     }     @Override     public Spliterator spliterator() {         return OrderedListADT.super.spliterator(); //To change body of generated methods, choose Tools | Templates.     }     @Override     public void add(T element) {         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.     } } OrderedListADT.java package jsjf; public interface OrderedListADT extends ListADT {     /**      * Adds the specified element to this list at the proper location      *      * @param element the element to be added to this list      */     public void add(T element); }
Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here