Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions