P ROBLEMUsing the given generic interface LinkedList.java and the generic class Node.java, create a class MyLinkedList.java which is a
generic class which implements LinkedList.java. It should contain the following attributes:
•
Node head – the first value of the linked list
As well as the following constructors/methods:
•
•
add(E item): void – Adds a new Node containing the item E to the end of the linked list.
add(E item, int loc): void – Adds a new Node containing the item E at the location loc, shifting the item already there
forward if necessary.
•
remove(E item): void – removes the first node containing a value equal to item, adjusting the order the linked list
traverses if necessary.
•
•
•
•
clear(): void – Empties the linked list entirely.
getSize(): int – returns the size of the list by traversing through the linked list.
getValue(int loc): E – returns the value of the node located at index loc.
indexOf(E item): int – returns the index of the first node that contains the value item.
rev. February 16 – 1 / 1