Question: Complete the MyLL class: package lab 0 8 ; public class MyLL { private class Node { public Node ( T val ) { data
Complete the MyLL class:
package lab;
public class MyLL
private class Node
public NodeT val data val;
public NodeT val, Node next data val; this.next next;
public T data;
public Node next;
private Node head;
MyLL
fill this in
public void InsertT previous, T value throws Exception
insert a new node with value "value" after the node with value "previous".
public void AppendT value
add a new node with value "value" at the end of the list. Head is a special case...
public boolean FindT value
return true if "value" is in the list, false if not
public boolean RemoveT value
remove "value" from the list. return true if it was found and removed, false otherwise
Tests that need to be passed:
package lab;
import static org.junit.Assert.;
import org.junit.Assert;
import org.junit.Test;
public class MyLLUnitTests
@Test
public void findWithEmptyList throws Exception
var ll new MyLL;
Assert.assertFalsellFindhello;
@Test
public void findWithNonEmptyList throws Exception
var ll new MyLL;
llAppendgoodbye;
Assert.assertFalsellFindhello;
@Test
public void findWithOneItemList throws Exception
var ll new MyLL;
llAppendhello;
Assert.assertTruellFindhello;
@Test
public void findWithManyItemList throws Exception
var ll new MyLL;
llAppendhello;
llAppendthere;
llAppendGeneral;
llAppendKenobi;
Assert.assertTruellFindhello;
Assert.assertTruellFindKenobi;
Assert.assertFalsellFindAnakin;
@Test
public void findThenRemoveThenAdd throws Exception
var ll new MyLL;
llAppendhello;
llAppendthere;
llAppendGeneral;
llAppendKenobi;
Assert.assertFalsellFindAnakin;
llRemoveKenobi;
Assert.assertFalsellFindKenobi;
llInsertGeneral"Anakin";
Assert.assertTruellFindAnakin;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
