Question: Create a JUnit test for the NewMain class. package package4; import java.util.* ; import java.io.* ; public class NewMain { /* *@return boolean *@param data

Create a JUnit test for the NewMain class.

Create a JUnit test for the NewMain class. package package4; import java.util.*

package package4;

import java.util.* ; import java.io.* ; public class NewMain {

/* *@return boolean *@param data */ public boolean checkPalindrome(LinkedList data) { //create variable len equal to data.size() int len = data.size() ; //List Iterator front equal to data 0 ListIterator front = data.listIterator(0) ; //List Iterator back equal to data len ListIterator back = data.listIterator(len) ; //counter set to 0 int counter = 0 ; //palindrome variable set to true boolean palindrome = true ; //if statement if(len%2 == 0) { int mid = len / 2 ; while( front.hasNext() && back.hasPrevious()) { if(counter == mid) { break ; } if(!Objects.equals(front.next(), back.previous())) { palindrome = false ; break ; } counter++ ; } } else { int mid = ((int) len / 2) + 1 ; while(front.hasNext() && back.hasPrevious()) { if(front.next() != back.previous()) { palindrome = false ; } if (counter == mid) { break ; } counter++ ; } } return palindrome ; } /** * @param args the command line arguments */ public static void main(String[] args) { MyVector pal = new MyVector() ; LinkedList word = new LinkedList() ; try { String data ; File file = new File("palindrome.txt") ; Scanner read = new Scanner(file) ; data = read.next() ; System.out.println(data) ; for(int i = 0 ; i

MyVector Class

package package4 ;

//import import java.util.ArrayList ;

public class MyVector { private ArrayList vector ; //constructor public MyVector(double[] values) { this.vector = new ArrayList() ; for (int i = 0 ; i

//copy constructor public MyVector(MyVector vec) { this.vector = new ArrayList() ; for (int i = 0 ; i 1. Creation of project 4. Package should include the driver and driver test classes /10 2. Used the MyVector class from projecti /10 3. Read input from a file generating MyVector objects......... /10 4. Used a LinkedList to store the MyVector objects ....... /10 5. Used two LinkedList iterators to traverse the LinkedList both directions ....... /10 6. Sequence compilation and execution Class compiles without errors b. Correct answers on test data ..... a. /10 /15 7. JUnit tests Provides at least one test for the method for recognizing a palindrome. a. /10 1. Creation of project 4. Package should include the driver and driver test classes /10 2. Used the MyVector class from projecti /10 3. Read input from a file generating MyVector objects......... /10 4. Used a LinkedList to store the MyVector objects ....... /10 5. Used two LinkedList iterators to traverse the LinkedList both directions ....... /10 6. Sequence compilation and execution Class compiles without errors b. Correct answers on test data ..... a. /10 /15 7. JUnit tests Provides at least one test for the method for recognizing a palindrome. a. /10

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!