Question: DEQueue Class public class DEQueue implements DequeInterface { protected DLLNode front; protected DLLNode rear; protected int numElements = 0; public DEQueue() { front = null;

DEQueue Class
public class DEQueue
protected DLLNode
public DEQueue() { front = null; rear = null; }
public boolean isFull() { return false; }
public boolean isEmpty() { return (numElements == 0); }
public int size() { return numElements; }
public void enqueueFront(T element) { DLLNode
public void enqueueRear(T element) { DLLNode newNode = new DLLNode(element); if (isEmpty()) { front = newNode; rear = newNode; } else { rear.setForward(newNode); newNode.setBack(rear); rear = newNode; } numElements++; }
public T dequeueFront() throws QueueUnderflowException { if (isEmpty()) { return null; } DLLNode newNode = front; front = front.getForward(); numElements--; if(!isEmpty()) front.setBack(null); return (T) newNode.getInfo(); }
public T dequeueRear() throws QueueUnderflowException { if (isEmpty()) { return null; } DLLNode newNode = rear; rear = rear.getBack(); numElements--; if(!isEmpty()) rear.setForward(null); return (T) newNode.getInfo(); }
public String toString() { String s = "
AppPart2 Class (ALL CODE GOES IN THIS CLASS UNDER //TODO(6) and //TODO(7)
public class AppPart2 {
public static void main(String[] args) { DEQueue
Scanner scan = new Scanner(System.in);
int operation; boolean keepGoing = true; while (keepGoing){ System.out.print("Choose an operation - "); System.out.print("1: insert, "); System.out.print("2: delete, "); System.out.println("3: quit");
if (scan.hasNextInt()) operation = scan.nextInt(); else{ System.out.println("Error: you must enter an integer."); System.out.println("Terminating test."); return; }
switch (operation){ case 1: //TODO(6) Implement the insert operation case 2: //TODO(7) Implement the delete operation case 3: keepGoing = false; System.out.println("Goodbye!!"); break; default: System.out.println("Error in operation choice. Terminating test."); return; } } scan.close(); } }
When inserting and deleting the deque must stay organized alphabetically by the first letter.
The delete case should prompt the user for what name to be deleted.
Part-2 An incomplete application program is given to you - App Part2.java. We want the program to use a DEQueue object to create a sorted list of names. The program gives a user the following three options to choose from insert, delete, and quit. If the user selects insert, the program should accept a name (String type) from the user and insert it into the deque in a sorted manner. If the user selects 'delete, the program should accept a name (String type) from the user and delete that name from the deque. Display the contents of deque after each insert/delete operation. The program continues to prompt the user for options until the user chooses to quit. You have to implement the insert and delete operations in the given incomplete program (see line#36, 38). You can make the following assumptions: User always tries to insert/delete a string type value only, i.e., you don't have to worry about wrong input type from the user. In case of repeated values, delete operation will delete the first occurrence only
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
