Implementation The starter code includes List.java. You should not change anything in List.java.
Your task will be to create LinkedList.java, make LinkedList use generics and inherit from List,
and complete several methods in LinkedList.java. Create LinkedList.java in IntelliJ. Add a main
method to LinkedList.java containing the following code. Your program will not compile again.
public static void main(String[] args) { LinkedList list = new LinkedList();
System.out.println(list.getHead()); System.out.println(list.getTail()); list.add("first");
list.add("middle"); list.add("last"); System.out.println(list.getHead().value);
System.out.println(list.getTail().value); System.out.println(list); } The first issue is that your
LinkedList class does not have a way of specifying what type of data it should store. You can fix
this using Java Generics. Change the first line of your class to the following: LinkedList .
Confirm that the first line in your main method no longer has an error. On the line that declares
the LinkedList class, add extends List before the bracket that begins the class. The first line in
your class will now have a compile error because LinkedList does not implement the methods
required by the List abstract class. Press Ctrl-i to have IntelliJ insert stubs of these methods.
Ensure that Copy JavaDoc is selected so you get JavaDoc comments which describe the method
requirements, then click OK. Your code should now compile again. Next add fields for the head
and tail. These will be of type Node. Create a getHead method which returns your head field, and
a getTail method which returns your tail field. Run your main method now and you will see that
there is a NullPointerException because the add method does not actually add anything to the
list, so head and tail will always be null. Complete the method boolean add(T value) for which
IntelliJ gave you a stub. You need to create a new node with value to add at the end of the list.
This means you will need to connect it to the old tail and update tail to point to the node you
created. Make sure that you handle the case where the list is empty and both head and tail should
be set to the new node you've created. Note: For the full Map I assignment, add will need to
prevent duplicate values being added to the list and should return true or false based on whether
the value was added or not. For this lab, you can ignore this requirement and simply return true.
Add a toString method to your LinkedList class. It should start at the head of your list and
proceed through all the nodes in a loop, combining the values of each node with a comma
between each and square brackets containing the whole thing. When you run your main method,
the final thing printed should be: [first, middle, last] List.java: /** * Specification for a List
ADT. * @author Shubham Chatterjee * @version 03/07/2019 * @param Type */ public abstract
class List { /** * Appends the specified value to the end of this list. * * @para.
MARGINALIZATION (Different learners in Marginalized Group
Implementation The starter code includes List.java. You should not c.pdf
1. Implementation The starter code includes List.java. You should not change anything in List.java.
Your task will be to create LinkedList.java, make LinkedList use generics and inherit from List,
and complete several methods in LinkedList.java. Create LinkedList.java in IntelliJ. Add a main
method to LinkedList.java containing the following code. Your program will not compile again.
public static void main(String[] args) { LinkedList list = new LinkedList();
System.out.println(list.getHead()); System.out.println(list.getTail()); list.add("first");
list.add("middle"); list.add("last"); System.out.println(list.getHead().value);
System.out.println(list.getTail().value); System.out.println(list); } The first issue is that your
LinkedList class does not have a way of specifying what type of data it should store. You can fix
this using Java Generics. Change the first line of your class to the following: LinkedList .
Confirm that the first line in your main method no longer has an error. On the line that declares
the LinkedList class, add extends List before the bracket that begins the class. The first line in
your class will now have a compile error because LinkedList does not implement the methods
required by the List abstract class. Press Ctrl-i to have IntelliJ insert stubs of these methods.
Ensure that Copy JavaDoc is selected so you get JavaDoc comments which describe the method
requirements, then click OK. Your code should now compile again. Next add fields for the head
and tail. These will be of type Node. Create a getHead method which returns your head field, and
a getTail method which returns your tail field. Run your main method now and you will see that
there is a NullPointerException because the add method does not actually add anything to the
list, so head and tail will always be null. Complete the method boolean add(T value) for which
IntelliJ gave you a stub. You need to create a new node with value to add at the end of the list.
This means you will need to connect it to the old tail and update tail to point to the node you
created. Make sure that you handle the case where the list is empty and both head and tail should
be set to the new node you've created. Note: For the full Map I assignment, add will need to
prevent duplicate values being added to the list and should return true or false based on whether
the value was added or not. For this lab, you can ignore this requirement and simply return true.
Add a toString method to your LinkedList class. It should start at the head of your list and
proceed through all the nodes in a loop, combining the values of each node with a comma
between each and square brackets containing the whole thing. When you run your main method,
the final thing printed should be: [first, middle, last] List.java: /** * Specification for a List
ADT. * @author Shubham Chatterjee * @version 03/07/2019 * @param Type */ public abstract
class List { /** * Appends the specified value to the end of this list. * * @param value T The
value to add * @return boolean True if the value is inserted, false otherwise */ abstract boolean
add(T value); /** * Inserts the specified value at the specified position in this list. * * @param
index Integer The index at which to insert * @param value T The value to insert */ abstract void
2. add(int index, T value); /** * Removes all of the elements from this list. */ abstract void clear();
/** * Returns true if this list contains the specified element. * * @param o Object The element to
check if present in the list * @return boolean */ abstract boolean contains(Object o); /** *
Returns the element at the specified position in this list. * * @param index Integer The index at
which to insert * @return T */ abstract T get(int index); /** * Get the list entry corresponding to
the value provided in the parameter. * @param o to search for * @return T matching data in the
list */ abstract T get(Object o); /** * Removes the element at the specified position in this list. *
Returns the element from the list or null if index is invalid. * * @param index the index of the
element to be removed * @return the element previously at the specified position or null */
abstract T remove(int index); /** * Removes the first occurrence of the specified element from
this * list, if it is present. * If this list does not contain the element, it is unchanged. * Returns
true if this list contained the specified element * (or equivalently, if this list changed as a result
of the call). * * @param o element to be removed from this list, if present * @return true if this
list contained the specified element */ abstract boolean remove(Object o); /** * Returns true if
this list contains no elements. * * @return true if this list contains no elements */ abstract
boolean isEmpty(); /** * Returns the number of elements in this list. * @return int */ abstract int
size(); /** * Inner class to represent a List node. */ public class Node { T value; Node prev;
Node next; /** * Constructor. * * @param value V The value */ public Node(T value) {
this.value = value; this.prev = null; this.next = null; } } }