Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this lab. List Exercise Use eclipse for this exercise. Part 1 Copy all files from Files, List Exercise folder. Create a

image text in transcribedimage text in transcribedimage text in transcribedI need help with this lab.

List Exercise Use eclipse for this exercise. 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 My List 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 NoSuchElementException String removeFront(): remove the first item in the list and return it; throw NoSuchElementException 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 My List 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 My List remove and then print each the first two items from the MyList print the MyList 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() 1/ 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; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago