An Interactive Test Application You will create an interactive application that
ID: 3593352 • Letter: A
Question
An Interactive Test Application You will create an interactive application that will create a list with five random numbers, show it, and present the following menu to the user: (73)->[67]->[2]->[16]->(92]-!! [Rjandom [Alfter [BJefore [DJelete [SJearch [P] Previous [N] Next [Hlome [EJnd The user will be able to add a random number after the current position (marked by braces), insert a number before or after the current position, delete the node at the current position, search for an item that may be in the list, or navigate the current position to the next or previous node, or to go to the home position, or the end of the list. (I will be so proud of you if you simply copy the test function from your Simple List assignment and paste and use it here. Very few modifications: just change the class to list iterated and change your cursor and other pointers to Iterators of the iterated list class. The reset will remain the same.) Note: The cursor position is maintained in the test function and NOT in the List class. The posiiton of the cursor is shown by a pair of braces'and it will be adjusted appropriately as operations are executed. Deleting a node will cause the cursor position to be set to the beginning of the list. (Why is that?)Explanation / Answer
Scanner input = new Scanner (System.in); LinkedList songList = new LinkedList(); ListIterator iter = new songList.listIterator(); boolean done = false; while (!done) { System.out.print ("Please enter a command (add, remove, print or quit): "); String command = input.nextLine(); if (command.equals(QUIT)) { // If quit, then exit the loop. done = true; } else if (command.equals(ADD)) { addSong(songList, input); songCount++; } else if (command.equals(REMOVE)) { System.out.print ("Please enter song title: "); String removeTitle = input.nextLine(); while (iter.hasNext()) { String checkSong = iter.next().getTitle(); if (removeTitle.equals(checkSong)) { iter.remove(); } } } else if (command.equals(PRINT)) { . . . } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.