Purpose

Modify a Queue ADT implemented as a linked list.

Lab

You are to take this implementation and add the following UML specified method:

+moveToBack(T queueEntry) : void

moveToBack() takes an object in the queue and moves it to the back of the queue only if an object is already in the queue. If the object is not in the queue, moveToBack() does not affect the queue at all.

When moving an object to the back of the queue, the queue entry in the linked list before the object is moved and the queue entry in the linked list after the object is moved need to be updated so that the entry before and the entry after are linked to each other. In other words, moving the object should be equivalent to the logic of deleting an entry from the queue (which requires the linked list node before the deleted node and the linked list node after the deleted node become linked together), and then adding an entry at the end of the queue (which is adding a new node at the end of the linked list, and setting the node's next member equal to null).

Note that the implementation of the Queue ADT has an inner class called Node. Examine Node carefully, as well as the methods that use Node to create, add, and remove nodes from a linked list recall discussions of how a linked list uses the next reference when accessing linked list nodes. The Node inner class's logic needs to be taken into account when considering how to store the parameter passed to moveToBack() into the queue.

You should have a driver program, and that program needs to have a main() method as well as be a program that is run at the command line. The program should perform a loop, ask for input, and display output in the following way (note that the text in bold represents what the user inputs):

Input a list of items to be placed into a queue: 5 9 101 183 4893
Input the item that is to be move to the back: 5
Items in queue after one item was moved to the back: 9 101 183 4893 5
Do you want to continue (y/n): y

Input a list of items to be placed into a queue:
No items were placed in the queue.
Do you want to continue (y/n): y

Input a list of items to be placed into a queue: alpha bravo charlie delta echo
Input the item that is to be move to the back: zulu
The item you asked to move to the back was not ever present in the queue.
Do you want to continue (y/n): n
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.