Minimal Submitted Files: Assignment10.java Download Assignment10.java(This file does NOT need to…

Minimal Submitted Files:

Assignment10.java Download Assignment10.java(This file does NOT need to be modified)
LinkedList.java Download LinkedList.java(partially given, needs to add more code)
ListIterator.java Download ListIterator.java(This file does NOT need to be modified)

You are not allowed to use the Scanner class in this assignment and any assignment after this one. You will need to use InputStreamReader and BufferedReader (they are in java.io package) to process input and also take care of IOException.

Class Diagram:

In this Assignment, you are given three files Assignment10.java, LinkedList.java, ListIterator.java. You will need to add additional methods in the LinkedList class in the LinkedList.java file. The LinkedList will storestrings only.

Specifically, the following methods must be implemented in the LinkedList class:
(You should utilize listIterator() method already defined in the LinkedList class to obtain its LinkedListIterator object, and use the methods in the LinkedListIterator to traverse from the first element to the last element of the linked list to define the following methods.)
public String toString()

The toString method should concatenate strings in the linked list, and return a string of the following format:

{ Orange Banana Melon Apple }

Thus it starts with “{” and ends with “}”, andthere is a spacebetween strings and “{” or “}”. If the list is empty, it returns “{ }” with a space in between.

public int size()

The size method returns the number of strings that the linked list contains at the time when this method is called.

public int search(Object element)

The search method returns the index of the element (string). If the element does not exist, then it returns -1.

public Object get (int index)

The get method returns an element at the given index (passed as its parameter). If the parameter index is larger or is negative, it should throw an object of the type IndexOutOfBoundsException class.

public void add (int index, Object element)

The add adds the element at the specified index. The element at the index and any elements at the later indices will be shifted towards the end of the list. If the parameter index is larger or smaller than the existing indices, it should throw an object of the IndexOutOfBoundsException class.

public Object remove(int index)

The remove removes the element at the specified index and the removed element should be returned. If the parameter index is larger or smaller than the existing indices, it should throw an object of the IndexOutOfBoundsException class.

public void appendAfter(Object str1, Object str2)

The appendAfter method searches the first occurrence of the first parameter string (str1), and appends (add) the second parameter string (str2) after the first string occurrence.
If the linked list does not contain a string str1, then the second parameter string is added at the end of the linked list.

public int countOccurrences (Object element)

The countOccurrences method counts how many times the element appears in the linked list and returns it. It returns 0 if the element does not exist in the linked list

THE CLASS THAT NEEDS TO BE FINISHED

/**
A linked list is a sequence of nodes with efficient
element insertion and removal. This class
contains a subset of the methods of the standard
java.util.LinkedList class.
*/

import java.util.NoSuchElementException;
public class LinkedList
{
/**
Constructs an empty linked list.
*/
public LinkedList()
{
first = null;
}

/**
Returns the first element in the linked list.
@return the first element in the linked list
*/
public Object getFirst()
{
if (first == null)
throw new NoSuchElementException();
return first.data;
}

/**
Removes the first element in the linked list.
@return the removed element
*/
public Object removeFirst()
{
if (first == null)
throw new NoSuchElementException();
Object element = first.data;
first = first.next;
return element;
}

/**
Adds an element to the front of the linked list.
@param element the element to add
*/
public void addFirst(Object element)
{
Node newNode = new Node();
newNode.data = element;
newNode.next = first;
first = newNode;
}

public void add(int index, Object element)
{
ListIterator iterator = listIterator();
int count = 0;
int currentSize = size();
if(index < 0 || index > currentSize)
{
IndexOutOfBoundsException ex = new IndexOutOfBoundsException();
throw ex;
}

while(count <= currentSize)
{
if(count == index)
{
iterator.add(element);
return;
}
count ++;
iterator.next();

}//end while loop

}//end method

/*************** Add your methods here *******************************/
//get method gets the element at the parameter
//index in the linked list. If the index is out of bounds,
//then it throws an exception.
public Object get(int index)
{

}

//remove method removes the element at the parameter
//index in the linked list. If the index is out of bounds,
//then it throws an exception.
public Object remove(int index)
{

}

//search method returns the index of the parameter object
//in the linked list if it exists. It return -1 if it does not
//exits. If the index is out of bounds, then it throws an exception.
public int search(Object element)
{

}

//The appendAfter method searches the first occurrence
//of the first parameter string, and append(add)
//the second parameter string after the first string
//occurrence.
//If the linked list does not contain any string that is
//same as the first parameter string, then
//the second parameter string is added at the end of the
//linked list.
public void appendAfter(Object str1, Object str2)
{

}

//countOccurrences methods counts how many times the parameter object
//appears in the linked list and return the number. It returns 0
//if the parameter object does not exist in the linked list.
public int countOccurrences(Object element)
{

}

//The method size return the current size of the linked list,
//that is, the number of elements in it.
public int size()
{

}

//The toString method returns a string containing the content
//of the linked list. In this assignment, the linked list will
//contain only string, so it returns a concatenation of all strings
//in the linked list.
public String toString()
{

}

/***************************************************************/

/**
Returns an iterator for iterating through this list.
@return an iterator for iterating through this list
*/
public ListIterator listIterator()
{
return new LinkedListIterator();
}

private Node first;

private class Node
{
public Object data;
public Node next;
}

private class LinkedListIterator implements ListIterator
{ //instance variables for the ListIterator class
private Node position;
private Node previous;
/**
Constructs an iterator that points to the front
of the linked list.
*/
public LinkedListIterator()
{
position = null;
previous = null;
}

/**
Moves the iterator past the next element.
@return the traversed element
*/
public Object next()
{
if (!hasNext())
throw new NoSuchElementException();
previous = position; // Remember for remove

if (position == null)
position = first;
else
position = position.next;

return position.data;
}

/**
Tests if there is an element after the iterator
position.
@return true if there is an element after the iterator
position
*/
public boolean hasNext()
{
if (position == null)
return first != null;
else
return position.next != null;
}

/**
Adds an element before the iterator position
and moves the iterator past the inserted element.
@param element the element to add
*/
public void add(Object element)
{
if (position == null)
{
addFirst(element);
position = first;
}
else
{
Node newNode = new Node();
newNode.data = element;
newNode.next = position.next;
position.next = newNode;
position = newNode;
}
previous = position;
}

/**
Removes the last traversed element. This method may
only be called after a call to the next() method.
*/
public void remove()
{
if (previous == position)
throw new IllegalStateException();

if (position == first)
{
removeFirst();
}
else
{
previous.next = position.next;
}
position = previous;
}

/**
Sets the last traversed element to a different
value.
@param element the element to set
*/
public void set(Object element)
{
if (position == null)
throw new NoSuchElementException();
position.data = element;
}

}
}

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works
Receive a 100% original paper that will pass Turnitin from a top essay writing service
step 1
Upload your instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Pro service tips
How to get the most out of your experience with Online Academic Experts
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
Testimonials
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
Management
It's the second time I use this service and it does not let me down. Work quality is so good for its price!
Customer 452985, December 3rd, 2021
Social Sciences
Very fast report with excellent information on the topic. Thank you for your speedy service in such a short time.
Customer 453213, June 15th, 2022
Nursing
Impressive writing
Customer 452547, February 6th, 2021
Management
Thank you!!! I received my order in record timing.
Customer 452551, February 9th, 2021
Business Studies
Thank you so much! I had to take my dog to the ER and had no time for the assignment. I really appreciate your help! I can't thank you enough! I really appreciate the work and integrity put into it. Thank you for taking it seriously and not bullshiting the paper.
Customer 452815, July 26th, 2021
Health Care
The writer did not follow my choice of topic (Food/Water Insecurity, Hunger, & Poverty), the paper was instead written about Climate Change in Africa. However, the paper was still great and informative. Thank you!
Customer 452777, January 28th, 2022
English 101
IThank you
Customer 452631, April 6th, 2021
Management
It was gotten well after time I needed to make needed additions, but it is something that did help me. I could not get the concept of ho to start such a project but now reading this, I was over thinking the project it seems.
Customer 452801, July 19th, 2021
Criminal Justice
The paper was not accused of plagiarism and was written very well. I will let you know the grade once it is graded. Thank you
Customer 452671, April 26th, 2021
History
Don't really see any of sources I provided, but elsewise its great, thank you!
Customer 452697, May 8th, 2021
Nursing
thank you so much
Customer 452749, June 10th, 2021
Business and administrative studies
awesome work
Customer 453201, June 15th, 2022
11,595
Customer reviews in total
96%
Current satisfaction rate
3 pages
Average paper length
37%
Customers referred by a friend
OUR GIFT TO YOU
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat
AllEscortAllEscort
Live ChatWhatsApp
AllEscort