Question: public class LLNode { private LLNode link; private T info; public LLNode(t info) { this.info = info; link = null; } public void setInfo(t info)

 public class LLNode { private LLNode link; private T info; publicLLNode(t info) { this.info = info; link = null; } public voidsetInfo(t info) // Sets info of this LLNode. { this.info = info;

public class LLNode { private LLNode link; private T info; public LLNode(t info) { this.info = info; link = null; } public void setInfo(t info) // Sets info of this LLNode. { this.info = info; } public T getInfo() // Returns info of this LLNode. { return info; } public void setLink(LLNode link) // Sets link of this LLNode. { this. link = link; } public LLNode getLink // Returns link of this LLNode. { return link; } } Part 1 Copy all files from Files, List Exercise folder. Create a class called MyList which will hold Strings. The field in MyList is LLNode head; Create the following methods of MyList: default constructor: initialize head to null constructor with a String parm: create a list containing the parm .toString: return a String that contains all Strings in the list, separated by newlines void addAtFront(String newstr): add newstr to the front of the list boolean contains(String item): return true if item is in the list; return false if not Create a class to contain main; main should do the following: create a new MyList object that contains "blue"; for all of the following steps use the methods of the MyList class (printing the MyList will automatically call the toString method) add "green" to the front of your MyList add "red" to the front of your MyList print the MyList prompt for a word, add it to the front prompt for another word, add it to the front print the My List prompt for a String, check whether it's in the MyList; print messages for when the String is found and when it's not found print the MyList Part 2 Add the following methods to your MyList class: void addAfter(String before, String newstr): add newstr to the list after before; if before is not in the list, throw No SuchElementException String removeFront(): remove the first item in the list and return it; throw NoSuch ElementException if the list is empty Add the following to the end of your client code: add "purple" after "green" add "aqua" after "purple" print the MyList prompt for two Strings, add the first after the second; if the second is not in the list (catch the exception) print a message stating that first could not be added because second is not in the MyList print the MyList remove and then print each the first two items from the MyList print the MyList

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!