Question: i need help to fix the code in bold as i am trying to make my remove method remove a specific elemnt but for some
i need help to fix the code in bold as i am trying to make my remove method remove a specific elemnt but for some reason i can't get it right so please help me correct it and tellme how i did wrong thank you and so long as you can make the test work with the method without changing the plus i'll be glad
thank you
the class that contains the remove method i wanna fix
package test2; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.ListIterator; import java.util.NoSuchElementException;
import javafx.scene.Node;
public class testing
public testing() { size =0; } /** * this class keeps track of each element information * @author * */ class Node
return this;} public T getFirst() { if(getHead()!=null) return getHead().data; else return null;} public T getLast() { if(getTail()!=null) return getTail().data;
else return null; }
public void remove(String string, Comparator
Node
public Node
public void setHead(Node
public Node
public void setTail(Node
its test
package test2;
import static org.junit.Assert.*;
import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; import java.util.ListIterator; import java.util.NoSuchElementException;
import org.junit.After; import org.junit.Before; import org.junit.Test;
public class testingTest { testing
@Before public void setUp() throws Exception { linkedString = new testing
@After public void tearDown() throws Exception { linkedString = null; comparator = null; }
@Test public void testAddToEnd() { assertEquals("World", linkedString.getLast()); linkedString.addToEnd("End"); assertEquals("End", linkedString.getLast()); }
@Test public void testAddToEndSTUDENT(){ //test addToEnd for the linkedDouble assertEquals("World", linkedString.getLast()); linkedString.addToEnd("End"); assertEquals("End", linkedString.getLast()); } @Test public void testAddToFront() { assertEquals("Hello", linkedString.getFirst()); linkedString.addToFront("Begin"); assertEquals("Begin", linkedString.getFirst()); }
@Test public void testAddToFrontSTUDENT(){ //test addToFront for the linkedDouble assertEquals("Hello", linkedString.getFirst()); linkedString.addToFront("Begin"); assertEquals("Begin", linkedString.getFirst()); }
@Test public void testRemove() { // remove the first assertEquals("Hello", linkedString.getFirst()); assertEquals("World", linkedString.getLast()); linkedString.addToFront("New"); assertEquals("New", linkedString.getFirst()); linkedString.remove("New", comparator); assertEquals("Hello", linkedString.getFirst()); //remove from the end of the list linkedString.addToEnd("End"); assertEquals("End", linkedString.getLast()); linkedString.remove("End", comparator); assertEquals("World", linkedString.getLast()); //remove from middle of list linkedString.addToFront("Begin"); assertEquals("Begin", linkedString.getFirst()); assertEquals("World", linkedString.getLast()); linkedString.remove("Hello", comparator); assertEquals("Begin", linkedString.getFirst()); assertEquals("World", linkedString.getLast()); } private class StringComparator implements Comparator
@Override public int compare(String arg0, String arg1) { // TODO Auto-generated method stub return arg0.compareTo(arg1); } } private class DoubleComparator implements Comparator
@Override public int compare(Double arg0, Double arg1) { // TODO Auto-generated method stub return arg0.compareTo(arg1); } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
